Forum Discussion

yybi123's avatar
yybi123
Helper I
5 years ago
Solved

Format value base on matrix row total

Hi, I have a matrix visual like below. How can I format the value base on the row total.  The value in this matrix is a Unit Price measure =  Sum(Price)/Sum(Unit) For example Non Premium Catego...
  • v-easonf-msft's avatar
    v-easonf-msft
    5 years ago

    Hi, yybi123 

    I create a demo based on you data. Please try  measures as below:

     

    Unit Price2 =
    VAR a =
        CALCULATE ( SUM ( 'Table'[Price] ), ALLSELECTED ( 'Table'[Name] ) )
    VAR b =
        CALCULATE ( SUM ( 'Table'[Unit] ), ALLSELECTED ( 'Table'[Name] ) )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Price] ) / SUM ( 'Table'[Unit] ),
            ALLSELECTED ( 'Table'[Name] )
        )
    
    Color measure =
    IF ( [Unit Price] < [Unit Price2], "tomato", "lightGreen" )
    

     

    Then apply the "Color measure" to conditional formatting.

    Result :

     

    Please check my sample pbix for more details.

    Best Regards,
    Community Support Team _ Eason
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.