Forum Discussion
Distinct Count with multiple conditions
- 3 years ago
I think I figured it out - I just had to switch the order of the last two statements, so the following seems to work:
ResponseIDCount = SWITCH(
TRUE(),
DISTINCTCOUNT( 'Table'[ResponseID] ) >= 15, DISTINCTCOUNT( ['Table'[ResponseID], DISTINCTCOUNT( 'Table'[ResponseID] ) = 0, 0,
DISTINCTCOUNT( 'Table'[ResponseID] ) < 15, "<15") - 3 years ago
KAmorris ,
You are close
SWITCH(TRUE(),Calculate(DISTINCTCOUNT(Table[Response_ID]), Table[Column]=1) >=15, DISTINCTCOUNT(Table[Response_ID]), Table[Column]=1)
// If Calculation is >= 15, then use the Calculation amountCalculate(DISTINCTCOUNT(Table[Response_ID]), Table[Column]=1) =0,0,
// If Calculation = 0, then 0.Calculate(DISTINCTCOUNT(Table[Response_ID]), Table[Column]=1) <15, "<15")
// If Calculation < 15, then use "<15". In Dax you can use "//" to make comments to yourself or others.Hope this added clarification helps.
KAmorris ,
The SWITCH function is similar to a nested IF statement. Please try this:
ResponseIDCount = SWITCH(
TRUE(),
DISTINCTCOUNT( 'Table'[ResponseID] ) >= 15, DISTINCTCOUNT( ['Table'[ResponseID] ),
DISTINCTCOUNT( 'Table'[ResponseID] ) < 15, "<15",
DISTINCTCOUNT( 'Table'[ResponseID] ) = 0, 0 )
Regards,
- KAmorris3 years agoFrequent Visitor
Thanks so much rsbin . Your suggestion seems to mostly work, but for some reason the count when the distinct count of 'Table'[ResponseID] should be 0 still shows up as "<15". Any other ideas or things I should check for?
- KAmorris3 years agoFrequent Visitor
I think I figured it out - I just had to switch the order of the last two statements, so the following seems to work:
ResponseIDCount = SWITCH(
TRUE(),
DISTINCTCOUNT( 'Table'[ResponseID] ) >= 15, DISTINCTCOUNT( ['Table'[ResponseID], DISTINCTCOUNT( 'Table'[ResponseID] ) = 0, 0,
DISTINCTCOUNT( 'Table'[ResponseID] ) < 15, "<15")