Forum Discussion

Imrans123's avatar
Imrans123
Advocate V
4 years ago
Solved

Showing a Measure as a Total Column only on Matrix

Hello,    I wanted to know if anyone could help me with the following trouble I am having. I have a matrix visual and I want to show a column with a measure as a total only without respective value...
  • v-yanjiang-msft's avatar
    4 years ago

    Hi Imrans123 ,

    According to your formula, in a measure, MAX and MIN will return the current value according to context, not the max or min value of the column, for example the Difference marked by the red line calculate by your formula is (12.2-12.2)/12.2=0.

    You can get a better understanding of context through this article:Context in DAX Formulas

     

    Here's my solution.

    Difference =
    VAR _MAX =
        MAXX (
            FILTER ( ALL ( Sheet1 ), 'Sheet1'[Item Code] = MAX ( 'Sheet1'[Item Code] ) ),
            'Sheet1'[Price]
        )
    VAR _MIN =
        MINX (
            FILTER ( ALL ( Sheet1 ), 'Sheet1'[Item Code] = MAX ( 'Sheet1'[Item Code] ) ),
            'Sheet1'[Price]
        )
    RETURN
        DIVIDE ( _MAX - _MIN, _MIN )
    

    Get the result.

    Reference for MAXX and MINX function: MAXX function (DAX) - DAX | Microsoft Docs

    MINX function (DAX) - DAX | Microsoft Docs

     

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.