Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
yybi123
Helper I
Helper I

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 Category the total is 4.4 , I want to format anything above it to be green and below to be red. In this case John and Will column will be green and Michelle will be red. 

 

It should be dynamic as the category being expanded to lower level with different row total. 
For example, Premium  - A row the colour format rule will be based on 4.67.

 

yybi123_0-1618466733525.png

Thank you.

1 ACCEPTED SOLUTION

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 :

93.png

 

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.

 

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@yybi123 , You can not color row in the matrix as of now. You have color all measures/values.

 

You can create a color measure based on a measure or column/row values and use that on  conditional formatting

using field value option

 

examples

 

Color sales = if([Sales Today] -[sales yesterday]>0,"green","red")

color =
switch ( true(),
FIRSTNONBLANK('Table'[commodity],"NA") ="commodity1" && sum('Table'[Value]) >500,"lightgreen",
FIRSTNONBLANK('Table'[commodity],"NA") ="commodity2" && sum('Table'[Value]) >1000,"lightgreen",
// Add more conditions
"red"
)

 

Refer to my video, how to do https://youtu.be/RqBb5eBf_I4

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

I am not too sure if this can be applied to my data. As I need to compare the value for each person by category against the total average of the category.

 

I do not have a measure that calculated the average by category ignoring the name. Do you know any dax I can achieve that? Then with that I can probably use your method above to colour code by applying rules if personal value greater than average value then green/red. 

 

Here is my data.

 

yybi123_0-1618468830042.pngyybi123_1-1618468853971.png

 

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 :

93.png

 

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.

 

sayaliredij
Super User
Super User

In Matrix, we have conditional formatting available. in Background control, you can click on advanced control and have following window to set your requirement

 

sayaliredij_0-1618467236532.png

Regards,

Sayali

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.