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
SysLostInBI
Frequent Visitor

Data color in table or matrix

Hi, Is it possible to have the table entries (for example rows) in the data color (the one that is also used in the visualization for bars etc).
I don't see how I can fix that with conditional formatting and it should not be static of course.

 
 
 

image.png

This example, I'd like to be able to not display a legend below, because the color match the entries in the table (either background, dots, or text color would be fine).

Thanks for your help

 

8 REPLIES 8
v-shex-msft
Community Support
Community Support

HI @SysLostInBI,

Perhaps you can try to use the custom theme to setting default data color sets, these charts and visual will auto transformed colors based on color dataset defend if you used legend on your charts.

Use report themes in Power BI Desktop 

AFAIK, conditions color formatting not works on the chart with legends. Perhaps you can refer to parry2k's suggestion to use R or python visual to manually plot your graph based on data table field values.

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
SysLostInBI
Frequent Visitor

Wow impressive, the amount of feedback in this short time.

I was pretty sure that my lack of experience is the problem - but seems to be a limitation. 

 

All your help is much appreciated, I wonder why nobody mentioned an R script solution. 
I'm not experienced enough yet - but do you think it is even possible / or the right solution to try it with an R script?

 

Btw, I'm not ignoring the solutions of using a table with colour or specify them with conditional-formating. I'm going to look into that of course.

@SysLostInBI you can surely use R script/visuals but you have to be careful when you publish these reports on Power BI Service and to make sure  R libraries you use, supported by Power BI service, otherwise if you have the skill set, you can surely use it. Just be cautious.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

swise001
Continued Contributor
Continued Contributor

@SysLostInBI 

 

Currently there's no 'automatic' way to link the colors used in the line chart to those used in the matrix/table. 

There's a modified work around you may consider - if you only have a handful of potential 'applications' - as it does involve setting the colors.  Consider the following: 

Result.png

In this example - you could use a SWITCH statement to declare the color of each 'application': 

  Row Colors = SWITCH(
                            SELECTEDVALUE('Table'[Item]),
                                    "Sample1","#79BEDB",
                                    "Sample2","#266A2E",
                                    "Sample3","#6B78B4")

Then set the conditional formatting of each column to "Field Value" - and point it to this formula.  
This can be done with every column in a Table visual as shown above - but only works with the 'values' columns if you use a Matrix. 
 
As for the line chart - there's no way "yet" to programmatically set the colors - or harness the same formula.  So you are stuck selecting each application - and setting a custom color using the hex codes - to match what was estabished above. 

However, once it's set up - it should persist - even as applications come and go.  But it will not account for new applications that aren't included in the list.  



fhill
Resident Rockstar
Resident Rockstar

This is the closest thing I could find currently available, but I don't it it will help, as when you add Application to the Legend of the Bar Chart, it will override these conditional colors...  

 

https://powerbi.jamesdales.com/2019/02/21/line-charts-with-conditional-formatting/

 

Hope you find something!

FOrrest




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




DataZoe
Employee
Employee

@SysLostInBI While you can't adjust the legend on a visual, you can try to match that matrix to match it.

 

I have data by US state names, and when I put that on a line chart, it defaults the legend to be alphabetical and the colors run through default colors. 

 

1. In transform data: I created a dimension table for the states, by duplicating the data table, choosing only the states column, removing duplicates, sorting it alphabetical, then added an Index Column. The goal is to get 0-49 for each of the state names starting with Alabama. It's great to that here so that if say a new state does get added, it will just add it automatically.

 

2. After applying those changes, I create a relationship to that dimension table on the state name. and change where i used that state name in my visuals to use the new dimension table version.

 

3. I then created a measure to get me the that index. 

Index Measure = min(Category[Index])
 
4. Then I created a conditional format on the matrix conditional formatting for background color (or font color, whatever you want) and you you set it up to be based on that "Index Measure" and simply choose the default colors would be starting with 0:
 
bgcolor.JPG

 

Just go across the top in the default colors, then 2nd row, etc. Mine also had some greens, so I just went and got it from the data colors that defaulted in on the line chart.
 
The end result is now the matrix will copy the default legend of the line chart.
 

bgcolor2.JPG

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

pranit828
Community Champion
Community Champion

Hi @SysLostInBI 

 

I would have loved if Power BI had a extensive functiolality like this.

You can post a Idea for the same.

 

As of Now, I would manually select the color for each datra in line chart conditional formatting is not an option for this

pranit828_0-1597422836910.png

, and conditionally format the top chart. 

 

Did I resolve your issue? Mark my post as a solution! Appreciate your Kudos, Press the thumbs up button!!

 

Regards,
Pranit

 





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
amitchandak
Super User
Super User

@SysLostInBI ,  Conditional formatting can not be done visual using legends

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.