Forum Discussion

Imrans123's avatar
Imrans123
Icon for Advocate V rankAdvocate 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 values.

 

Here's an example data set

 

 

I created a matrix visual as follows, 

 

From here I want to show, for a given Item Code, across companies, the highest value and the lowest value and what is the percentage difference. 

 

I made the following measure and added to the matrix 

Difference = (MAX(Sheet1[Price ])-MIN(Sheet1[Price ]))/MIN(Sheet1[Price ])
 

 

Here, on the total column, it's giving me the figures I want i.e. for C1 Max is 16.3, min is 15.2 and difference is 7%. However, it's adding additional columns for each company. Any way I could get rid of this and show only the total column??

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

     

     

7 Replies

  • Ali-Analyst's avatar
    Ali-Analyst
    Frequent Visitor
    Hello Team,

    I'm facing the same issue and wondering if there is a way to not show these extra columns added to matrix as show in below in the yellow and only show the column added after the Total column in Green?

     

    Any help would be greatly appreciated!

    Thanks,

    Ali

  • It's not too hard to write a measure that returns blank for each company column using ISINSCOPE, but that won't make them disappear (they'll just be blank instead of 0.00).

     

    A quick and dirty solution is to turn off word wrap and resize the columns to be effectively invisible.

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

     

     

  • Ali-Analyst's avatar
    Ali-Analyst
    Frequent Visitor

    Hello Team,
    I'm facing the same issue and wondering if there is a way to not show these extra columns added to matrix as show in below in the yellow and only show the column added after the Total column in Green?

    Any help would be greatly appreciated!

    Thanks,

    Ali