Forum Discussion

Nainan_Prov's avatar
Nainan_Prov
New Member
8 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 in a specific clinic or region at the bottom of the table. Usualy with the normal value, we can right click and select SUM, COUNT...But with this dynamic parameter, there is no such function. I guess it is the pivot table confusing, don't know if we have some way to do it.

Thanks ahead!

  • 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.

5 Replies

  • hello Nainan_Prov 

     

    i think it should be plausible.. have you tried using adding if statement in your calculation for dynamic change?

    Thank you.

  • 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.

  • Hi,

    Cannot understand your question.  Share the download link of the PBI file and show the expected result.

  • v-achippa's avatar
    v-achippa
    Icon for Community Support rankCommunity Support

    Hi Nainan_Prov,

     

    Thank you for reaching out to Microsoft Fabric Community.

     

    Thank you Irwan, Ashish_Mathur and krishnakanth240 for the prompt response. 

     

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user's for the issue worked? or let us know if you need any further assistance.

     

    Thanks and regards,

    Anjan Kumar Chippa

    • v-achippa's avatar
      v-achippa
      Icon for Community Support rankCommunity Support

      Hi @Nainan_Prov,

       

      We wanted to kindly follow up to check if the solution provided by the user's for the issue worked? or let us know if you need any further assistance.

       

      Thanks and regards,

      Anjan Kumar Chippa