DAX measure depending on multiple conditions

Viewed 834

I am new with Dax. I have a matrix table in Power BI which has been imported from Excel. I need to create a dynamic DAX measure which will give me the values if both conditions are filtered. This is a very big table and the measure has to be dynamic as values keep changing.

For eg:

Criteria : A, B, C
Code : 101,102,103
Values: 94, 50, 63
If Criteria is A and Code is 101 then value = 94
If Criteria is B and Code is 102 then value = 50
1 Answers

If you need measure based on columns that you put in your matrix on rows or columns, you may use this.

YourMeasure = IF( MAX( Tab[fruit] ) = "Apple" & MAX( Tab[size] ) = "Big", 1, 0 )

Probably what you are after, and what is safer, is adding new calculated column in your source table:

CalculatedColumn =
IF( 
    Tab[friut] = "Apple"      // condition 1 
    &                         // AND opperator
    Tab[size] = "Big",        // condition 2
    1,                        // result if true
    0                         // result if false
)

Where 1 is returned if both conditions are met.

If your condition path is complex you might use SWITCH function.

SWITCH( TRUE(),
   Tab[column1] = "Apple" & Tab[column2]="Big",   "Big Fruit",
   Tab[column1] = "Carot" & Tab[column2]="Small", "Small Vegetable",
   "Other thing"
)
Related