Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
test = IF( SELECTEDVALUE(PowerBiData[Afdeling];"PROD")="PROD";1 ) + IF( SELECTEDVALUE(PowerBiData[Afdeling];"MONT")="MONT";2 ) + IF( SELECTEDVALUE(PowerBiData[Afdeling];"ADM")="ADM";3 )
Hi,
I am trying to create a measure "test", which is to sum up/add each TRUE in a single value.
To elaborate, if statement 1 and 3 is found TRUE, then i would expect the value 4 (1+3=4).
I have a slicer, from where i select X different "Afdeling". So for each i select, my SELECTEDVALUE examines, whether each individual "Afdeling" is chosen, i.e. "PROD", "MONT", "ADM" and so on.
The thing is, the code works just fine if only one, none or all statements are true. But each time i choose between one and all, it will return the values as if in fact all statements were true.
Thanks in advance.
Solved! Go to Solution.
Hi @MSS
You may try below measure:
TestCalc = CALCULATE ( SUMX ( VALUES ( PowerBiData[Afdeling] ), SWITCH ( TRUE (), PowerBiData[Afdeling] = "ADM", 3, PowerBiData[Afdeling] = "Mont", 2, PowerBiData[Afdeling] = "Prod", 1 ) ) )
Regards,
Hi,
Try this and see if it gives the result you are after
TestCalc = CALCULATE(SUMX( Table; SWITCH ( TRUE (); Table[Column] = "ADM"; 1; Table[Column] = "Mont"; 2; Table[Column] = "Prod";3 ) ))
Just change the names of Table and column to your own
Hi,
Thanks for your answer,
Unfortunately, this returns the number of rows, which have "Afdeling" = the types selected on the slicer.
The 1, 2 and 3 are not really the end result im reaching for. I want to have an unique expression to be executed per TRUE if-statement. That is;
"Afdeling" = "PROD", then do x thing,
"Afdeling" = "ADM", then do y thing,
"Afdeling" = "MONT", then do z thing.
And again, the type of "Afdeling" is to be chosen on a Slicer within the report.
Hi @MSS
You may try below measure:
TestCalc = CALCULATE ( SUMX ( VALUES ( PowerBiData[Afdeling] ), SWITCH ( TRUE (), PowerBiData[Afdeling] = "ADM", 3, PowerBiData[Afdeling] = "Mont", 2, PowerBiData[Afdeling] = "Prod", 1 ) ) )
Regards,
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
115 | |
113 | |
105 | |
95 | |
58 |
User | Count |
---|---|
174 | |
147 | |
136 | |
102 | |
82 |