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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
haider378
Regular Visitor

Apply a color based on year (differentiate each year with different color)

Hi,

I have created a matix visual and I want to color each year to differenciate with other years

 

haider378_0-1608037992419.png

 

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

There @haider378

You can try using the conditional formatting function to add background colors to the value fields.

My sample table:

1.png

If the table is next, you may need to use unpivot to transform the table.2.png

Select Product Group and Range Column, and then select Other Columns.

3.png

Then you can get a new table like the first one.

Create an array visual by this table, rotate the Row subtotals.

4.png

Then use conditional formmating:

1. Format by rule

Color measurement:

Rule Color = 
Var _Range = MAX('Table'[Range])
Return
SWITCH(TRUE(),_Range="2017-18",1,_Range="2018-19",2,_Range="2019-20",3,4)

Result:

6.png

2.Format by field value

Color measurement:

Field Value Color = 
Var _Range = MAX('Table'[Range])
Return
SWITCH(TRUE(),_Range="2017-18","Red",_Range="2018-19","Green",_Range="2019-20","Blue","Yellow")

5.png

For more information, see this blog: Conditonal Format in Power BI

You can download the pbix file from this link: File

Best regards

Rico Zhou

If this post helps,then consider Accepting it as the solution to help other members find it faster.

View solution in original post

6 REPLIES 6
haider378
Regular Visitor

thank you so much for your detailed answar😊 appriciated

Hi @haider378 

I am so glad to solve your problem. Could you kindly accept the helpful reply as a solution?  More people will benefit from it. 

 

Best Regards,

Rico Zhou

v-rzhou-msft
Community Support
Community Support

There @haider378

You can try using the conditional formatting function to add background colors to the value fields.

My sample table:

1.png

If the table is next, you may need to use unpivot to transform the table.2.png

Select Product Group and Range Column, and then select Other Columns.

3.png

Then you can get a new table like the first one.

Create an array visual by this table, rotate the Row subtotals.

4.png

Then use conditional formmating:

1. Format by rule

Color measurement:

Rule Color = 
Var _Range = MAX('Table'[Range])
Return
SWITCH(TRUE(),_Range="2017-18",1,_Range="2018-19",2,_Range="2019-20",3,4)

Result:

6.png

2.Format by field value

Color measurement:

Field Value Color = 
Var _Range = MAX('Table'[Range])
Return
SWITCH(TRUE(),_Range="2017-18","Red",_Range="2018-19","Green",_Range="2019-20","Blue","Yellow")

5.png

For more information, see this blog: Conditonal Format in Power BI

You can download the pbix file from this link: File

Best regards

Rico Zhou

If this post helps,then consider Accepting it as the solution to help other members find it faster.

Hi @v-rzhou-msft 
No doubt your solution works, but is there any way to apply the same background to row headers as well?
In your case, can the bg color be applied to 2017-18,2018-19?

HI @v-rzhou-msft 
I was wondering if its possible to change the color for the "ROWS". I mean in your example should be: "ProductPage".

I have this:

Noredlac86_0-1676322553417.png


and i want to change the color of the rows (I mean the text in the first column, A) 0-15Days.... etc.

Im using matrix chart, if i use table chat, will work, but i need use matrix.

 

PhilipTreacy
Super User
Super User

Hi @haider378 

Do you want to change the color of the background behind the years in the Product Group column?  if soI'm afraid you can't in a matrix.  You can however change the colour of the values in the rows for example (this is a mock up)

matrix-bg-color-mockup.png

is that what you are after?

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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