Forum Discussion
patkang
5 years agoHelper I
Conditional output based on other DAX
Dear Community I am trying to create a text output if a countrow function produces a certain output. Consider the table below. It shows a list of positions that potential nominees will take ove...
- 5 years ago
patkang ,
with your sample data I get the following solution:
Nominees = VAR CountHighIntelligence = CALCULATE(COUNTROWS('Table'), 'Table'[Intelligence Id] = "High") RETURN IF(CountHighIntelligence < 2 , "risky" , IF(CountHighIntelligence >= 4 , "Strong nominess" , "not risky" ) )With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
patkang
5 years agoHelper I
FrankAT
Thanks a lot, They don't call him super user for no reason 🙂
On top of that, if I want to count the number of strong, risky or not risky positions. What measure could I apply for this? In that case it would be 3 times 1. But if i would have more than 3 positions and would want to aggregate the number of those positions, what would be the best way to do it?
FrankAT
5 years agoCommunity Champion
Hi patkang ,
in this case you should use the SWITCH() function, example
Nominees with SWITCH =
VAR CountHighIntelligence = CALCULATE(COUNTROWS('Table'), 'Table'[Intelligence Id] = "High")
RETURN
SWITCH(TRUE(),
CountHighIntelligence = 1 , "try again",
CountHighIntelligence = 2 , "nice try",
CountHighIntelligence = 3 , "correct",
CountHighIntelligence = 4 , "well done",
"Best Hiro"
)
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)