DAX containsrow function

dicken

Active Member
Joined
Feb 12, 2022
Messages
292
Office Version
  1. 365
Platform
  1. Windows
Hi,
Can someone help with Containsow and contains for that matter.

I have a table in Power pivot the in consist of 3 column Item , Unit and Product ,
the top row is A , 3 , X

so if I write a measure ;
VBA Code:
CONTAINSROW( Table2, "A", "3", "X" )
why do I get an error, it asked for a table, = Table2 and
then I give a single value for each of the columns of that table, so why the error?

Another example
Excel Formula:
ContainM:=VAR containV  = CONTAINS( Table2, Table2[Item] ,"C", Table2[Prodiuct] , "Z" ) 
RETURN
CALCULATE( COUNTROWS( Table2), FILTER( ALL(Table2[Prodiuct]),  containV  ))

This return 22 even though there are only two rows of Table2 that would give a TRUE to the contains ?
I was expecting a the same as ;
Excel Formula:
CALCULATE( COUNTROWS( Table2), FILTER( ALL( Table2[Prodiuct], Table2[Item]) , Table2[Item] = "C" && Table2[Prodiuct] = "Z" ))



Richard.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
CALCULATE( COUNTROWS( Table2), FILTER( ALL(Table2[Prodiuct]), containV ))
You are passing one True/False value to the filter here, so it's the same for all rows of the table.
 
Upvote 0
Solution
You are passing one True/False value to the filter here, so it's the same for all rows of the table.
Of all the DAX functions I find CONTAINS , CONTAINSROW and IN the most confusing, so times I get just what I want
when tested and checked against the source, other times not, it's one I'm wary of using.
Richard.
 
Upvote 0
I'm not sure what is confusing you. They just return a True/False value depending on whether the table contains a row that matches the values specified. IN is basically just a shorthand form of CONTAINSROW
 
Upvote 0
I'm not sure what is confusing you. They just return a True/False value depending on whether the table contains a row that matches the values specified. IN is basically just a shorthand form of CONTAINSROW
I'm not sure what is confusing you. They just return a True/False value depending on whether the table contains a row that matches the values specified. IN is basically just a shorthand form of CONTAINSROW
It's when I try to use with filter, also that ' Contians, Containsrwo and IN' all seem to have a different syntax order,
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

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