Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

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

  • 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's avatar
      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.