Forum Discussion
Switching Calculation with Field Parameters in Power BI Visuals
- 2 years ago
Hi Ronald123 ,
Redo the measure to:
Total Sum = VAR _a = SELECTCOLUMNS ( Parameter, "Name",[Parameter]) RETURN SUMX ( _a, SWITCH ( [Name], "APPEL", [APPEL], "ORANGE", [ORANGE], "BANANA", [BANANA], 0 ) )I added a new row Banana to get some different results but it's working has needed:
Hi Ronald123 ,
To what I can understand you want to be abble to make the sum of the selected measure based on the field parameter?
So for example if you selecte Measure A and the values are 1 , 2, 3 you get 6 if you selecte measure B and the values are 4, 5, 6 you get 15. Is this correct?
In this case you i believe you have two options one is two create a measure that uses a switch function changing the context of your calculation it would be something similar to this:
Total Sum = SUMX (
ADDCOLUMNS (
VALUES ( Table[Column] ),
"ValuesTotal",
SWITCH (
SELECTEDVALUE ( Parameter[Parameter Order] ),
0, [Measure A],
1, [Measure B],
2, [Measure C]
)
),
[ValuesTotal]
)
Another option that you have is to have a calculation group created using tabular editor that way the measure would be different:
SUMX (
ADDCOLUMNS (
VALUES ( Table[Column] ),
"ValuesTotal", SELECTEDMEASURE ()
),
[ValuesTotal]
)
Check this link for the Calculation groups option:
https://www.sqlbi.com/articles/introducing-calculation-groups/
https://www.sqlbi.com/calculation-groups/
The combination of calculation items with field parameters is very powerfull.