Forum Discussion

jaythakur32's avatar
jaythakur32
New Member
2 years ago
Solved

How to highlight maximum and minimum values?

Hi,

I am new to PBI and find it difficult to highlight the maximum and minimum values row-wise using DAX in the visual (matrix table). I have rows as Product Names from the Product table, columns as Warehouse Name from the Sales Order table, and values as total revenue (which is a measure created on the Sales Order table).

 

I want to know the maximum and minimum revenue generated from which warehouse for each product.

 

Below are the screenshots of Visual and column names


 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi jaythakur32 

     

    Based on your needs, I have created the following table.

     

    You can use the following dax to get the result you want.

    Measure 2 = var _tab=SUMMARIZE(ALLSELECTED('Table (2)'[area]),'Table (2)'[area], "@sumvalue",CALCULATE(SUM('Table (2)'[value])))
    var _max= maxx( _tab,[@sumvalue])
    var _min= MINX(_tab,[@sumvalue])
    var _area=SELECTEDVALUE('Table (2)'[area])
    return  SWITCH(TRUE(),sum('Table (2)'[Value])=_max&&_area="a","grey", sum('Table (2)'[Value])=_max&&_area= "b","grey",sum('Table (2)'[Value])=_max&&_area="c","grey",sum('Table (2)'[Value])=_max&&_area="d","grey",sum('Table (2)'[Value])=_min&&_area="a","green", sum('Table (2)'[Value])=_min&&_area= "b","green",sum('Table (2)'[Value])=_min&&_area="c","green",sum('Table (2)'[Value])=_min&&_area="d","green")

     

     

     

     

    Best Regards,

    Jayleny

     

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

2 Replies

  • That's pretty straightforward if your data is in the right format (as it seems to be).  You need to compare each value agains the min and max value that you get when you apply REMOVEFILTERS(...[Warehouse Code])

     

    Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

    Do not include sensitive information or anything not related to the issue or question.

    If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216

    Please show the expected outcome based on the sample data you provided.

    Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi jaythakur32 

     

    Based on your needs, I have created the following table.

     

    You can use the following dax to get the result you want.

    Measure 2 = var _tab=SUMMARIZE(ALLSELECTED('Table (2)'[area]),'Table (2)'[area], "@sumvalue",CALCULATE(SUM('Table (2)'[value])))
    var _max= maxx( _tab,[@sumvalue])
    var _min= MINX(_tab,[@sumvalue])
    var _area=SELECTEDVALUE('Table (2)'[area])
    return  SWITCH(TRUE(),sum('Table (2)'[Value])=_max&&_area="a","grey", sum('Table (2)'[Value])=_max&&_area= "b","grey",sum('Table (2)'[Value])=_max&&_area="c","grey",sum('Table (2)'[Value])=_max&&_area="d","grey",sum('Table (2)'[Value])=_min&&_area="a","green", sum('Table (2)'[Value])=_min&&_area= "b","green",sum('Table (2)'[Value])=_min&&_area="c","green",sum('Table (2)'[Value])=_min&&_area="d","green")

     

     

     

     

    Best Regards,

    Jayleny

     

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