Forum Discussion

Nainan_Prov's avatar
Nainan_Prov
New Member
9 months ago
Solved

Can we calculate a dynamic parameter in Matrix Value

I created a parameter with different values, like sum of numerator, denominator and total care gaps. In my matrix table, I put this dynamic parameter in the value. I want to see the sum of total cols...
  • krishnakanth240's avatar
    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 Values

    Replace:
    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.