Forum Discussion
Lsh0576
3 years agoFrequent Visitor
DAX Query Help!
Hello there, I was wondering if someone can assist me with a PowerBi query I am trying to do. I have two spreadsheets (Master Name) and (Transactions). I would like to do a calculation of the num...
- 3 years ago
Lsh0576 Might be better if you unpivoted your columns in your second table but you can use the concept from MC Aggregations for this: Multi-Column Aggregations (MC Aggregations) - Microsoft Power BI Community
Should go something like:
# of Occurences Measure = VAR __Column1 = SELECTCOLUMNS('Transactions',"Customer Name", [Customer Name 1]) VAR __Column2 = SELECTCOLUMNS('Transactions',"Customer Name", [Customer Name 2]) VAR __Column3 = SELECTCOLUMNS('Transactions',"Customer Name", [Customer Name 3]) VAR __Table = UNION( __Column1, __Column2, __Column3 ) VAR __MasterNames = SELECTCOLUMNS( 'Master',"Customer Name", [Customer Name] ) VAR __Count = COUNTROWS( FILTER( __Table, [Customer Name] IN __MasterNames) ) RETURN __Count
Greg_Deckler
3 years agoCommunity Champion
Lsh0576 Might be better if you unpivoted your columns in your second table but you can use the concept from MC Aggregations for this: Multi-Column Aggregations (MC Aggregations) - Microsoft Power BI Community
Should go something like:
# of Occurences Measure =
VAR __Column1 = SELECTCOLUMNS('Transactions',"Customer Name", [Customer Name 1])
VAR __Column2 = SELECTCOLUMNS('Transactions',"Customer Name", [Customer Name 2])
VAR __Column3 = SELECTCOLUMNS('Transactions',"Customer Name", [Customer Name 3])
VAR __Table = UNION( __Column1, __Column2, __Column3 )
VAR __MasterNames = SELECTCOLUMNS( 'Master',"Customer Name", [Customer Name] )
VAR __Count = COUNTROWS( FILTER( __Table, [Customer Name] IN __MasterNames) )
RETURN
__Count