Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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,
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |