Forum Discussion
Can we calculate a dynamic parameter in Matrix Value
- 9 months ago
Hi
Yes, it is possible but not via the Matrix “Summarize” option. With Field Parameters, totals must be handled in DAX not through the visual UI.
SUM option disappears with Field Parameters? Field parameter is not a column, it’s a measure switch
So, Matrix can’t apply Sum / Count / Avg automatically
We must define how totals behave inside the measure> Example field parameter
Assume your parameter switches between:
Numerator
Denominator
Total Care Gaps
Your parameter-generated measure looks like this:Selected Metric =
SWITCH (
SELECTEDVALUE ( 'Metric Parameter'[Metric] ),
"Numerator", [Numerator],
"Denominator", [Denominator],
"Total Care Gaps", [Total Care Gaps]
)This works for row-level values & totals need special logic.
> Fix Grand Total behavior using ISINSCOPE
Selected Metric (With Total) =
VAR MetricValue =
SWITCH (
SELECTEDVALUE ( 'Metric Parameter'[Metric] ),
"Numerator", [Numerator],
"Denominator", [Denominator],
"Total Care Gaps", [Total Care Gaps]
)RETURN
IF (
ISINSCOPE ( Clinic[Clinic] ), -- row level
MetricValue,
-- total level
SUMX (
VALUES ( Clinic[Clinic] ),
MetricValue
)
)
Rows → normal calculation
Grand Total → iterates clinics and sums results correctly
>Use this measure in the Matrix ValuesReplace:
Original parameter measure
With:
Selected Metric (With Total)
Turn Row subtotals / Grand totals ON in Matrix formatting.
You cannot use:
Right-click → Sum / Count
“Summarize by” options
These are disabled by design for parameters.If you want different total logic per metric
You can customize totals per selection:
IF (
NOT ISINSCOPE ( Clinic[Clinic] ),
SWITCH (
SELECTEDVALUE ( 'Metric Parameter'[Metric] ),
"Numerator", SUMX ( VALUES ( Clinic[Clinic] ), [Numerator] ),
"Denominator", SUMX ( VALUES ( Clinic[Clinic] ), [Denominator] ),
"Total Care Gaps", SUMX ( VALUES ( Clinic[Clinic] ), [Total Care Gaps] )
),
MetricValue
)Field Parameters push aggregation responsibility to DAX.
If you want totals, we must explicitly define them.
hello Nainan_Prov
i think it should be plausible.. have you tried using adding if statement in your calculation for dynamic change?
Thank you.