DAX contains / row syntax

dicken

Active Member
Joined
Feb 12, 2022
Messages
292
Office Version
  1. 365
Platform
  1. Windows
I have sort of addressed this problem on excel forum ;
Excel Formula:
https://www.excelforum.com/office-365/1414306-dax-contains-for-or-conditions.html#post5885588

Can someone explain the following I have a few examples of CONTAINS / ROW
These are calculated columns;
Excel Formula:
A  CONTAINS( Table1,Table1[Name],"tom")
B  CALCULATE(  CONTAINSROW( VALUES( Table1[Name]) , "tom") ) 
C    CONTAINSROW({"tom"}, Table1[Name] )

All these produce a correct true false for the row, but why does B need calculate ?

But if I write a measure for containsrow it then needs ;
Excel Formula:
CONTAINSROW( VALUES(Table1[Name]), "tom")
even though most of the online examples follow a pattern ;

Excel Formula:
CONTAINSROW ( { "Red", "Blue", "Yellow" }, Product[Color] )

when I try
Excel Formula:
CONTAINSROW( {"tom"}, Table1[Name])
it just get an error ?

Richard.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You haven’t mentioned the name of the table you’re adding the calc column to, nor any relationships in your model. If I assume it’s Table1, then the issue is the use of values() in B. Values() produces a new table that is not included in the row context of the calc column in Table1. Calculate forces context transition which takes the row context from the calculated column and applies it as a filter context to the values(). Values then has a single value, hence it works. Without calculate, the values() contains all unique values in column Table1[name]. If you remove values(), then table1[name] has a single value by nature of the calculated column row context hence the calculate function is not needed. This assumes the cc is added to Table1
 
Upvote 0
There are no relationships, its a single column table with a name in each cell,
if you don't use Values then

Excel Formula:
CONTAINSROW( Table2[Names] ,"Tom")
= Errors for each row of the calculated column,

Excel Formula:
CONTAINSROW( VALUES( Table2[Names]), "Tom")
= True and then calculate = true just for the correct rows. ?


Any views on how the measures work as to which needs to

CONTAINSROW( VALUES(Table1[Name]), "tom")
CONTAINSROW( {"tom"}, Table1[Name])

Most of the articles seem to the second syntax and it's used in MS docs, I just get an error.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top