Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX conditional on multiple text columns

Hi,

 

I am looking to create a measure that is conditional on two attributes. 

 

Unfortunately I am not able to come up with the DAX expression that allows me to reference Customer[Group] or Sales[Category].

 

It relates to two different data tables below.

 

Customer table:

GroupNameRate
AJohn50%
BFred50%
CAlex100%

 

Sales table:

NameCategoryAmount
JohnFood100
JohnBeverage200
FredFood50
FredBeverage50
FredEquipment100
AlexFood200
AlexBeverage50
AlexEquipment100

 

I was thinking I would need to use SUMX, but also thought it would work like below;

 

New Rate = IF(Customer[Group]="B" && Sales[Category]="Equipment", 100% , else Customer[Rate])

 

New Amount= sum(Sales[Amount]) * [New Rate]

 

End result should be;

NameCategoryNew Amount
JohnFood50
JohnBeverage100
FredFood25
FredBeverage25
FredEquipment100
AlexFood200
AlexBeverage50
AlexEqiupment100

 

and it needs to work on an aggregate basis too;

 

NameNew Measure
John150
Fred150
Alex350

 

Thanks in advance!

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Try like

New Rate = IF(maxx(filter(Customer, Customer[name] =sales[name]),Customer[Group])="B" && Sales[Category]="Equipment", 100% , else Customer[Rate])

 

or

 

New Rate = IF(related(Customer[Group])="B" && Sales[Category]="Equipment", 100% , else Customer[Rate])

 

 

Anonymous
Not applicable

Thanks @amitchandak ,

 

The first option almost works, but I cannot reference sales[name] for the filter part, as it is in a different table I believe.

 

Unfortunately the second option is exactly what I had in mind, but I cannot reference either Group or Category.  It only lets me reference measures.

@Anonymous , first one should work as new column in sales, Are you trying as measure.

 

refer my video - https://www.youtube.com/watch?v=czNHt7UXIe8

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors