Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi PBI community,
Is there a way to change the background or font color of a table cell for a text based column using DAX.
Any help would be appreciated.
Thank you!
If you are looking to use DAX, here is an easy formula to use.
Title =
VAR Name1 = IF(SELECTEDVALUE('TABLE'[COLUMN]) = "TEXT", True, False)
VAR Name2 = IF(SELECTEDVALUE('TABLE'[COLUMN]) = "TEXT", True, False)
VAR Name3 = IF(SELECTEDVALUE('TABLE'[COLUMN]) = "TEXT", True, False)
RETURN
SWITCH(
TRUE(),
Name1 , "COLOR",
Name2, "COLOR",
Name3, "COLOR")
You would just need to type in the table names and columns. This method would require you to type in all of the cell contents that you want to format, but it works great for smaller distinct value distributions.
Hi, I am working on a similar stuffs where I need the text to have colors. I have a rating column ratings=0 are detractors, raating=1 are promotors and rating =2 are passive. So I want the comments(text) associated with this ratings to follow the same color but it is not working is there a way to solve the problem
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
This method works perfectly in the Sept. 2021 version. Simply create a Calculated Column based on the original column using the method above (Hex color codes). Then do conditional formattting on the original field in a table or matrix and pick "Format by" > "Field value", "Based on field" > Your calculated column.
This post provides one method: https://exceleratorbi.com.au/conditional-formatting-with-a-text-field-in-power-bi/
The DAX is essentially:
I have found a solution which may help which I got help from one of my team members:
This is a perfect and simple way. Thanks so much. You saved a lot of my time.
This is genius thank you!
This is a huge discovery for me. Thank you!!!
This one helped me solve a problem, one that blocked me all day, many thanks! I got as far as you did up to creating a column to be numbers assigned from another column that is Red, Amber, Green until the conditional formatting lost me, but you helped me solve that one.
The business logic was to calculate the number of months between now and a future date, then using business rules to create a RAG upon them.
Red -> Months to Expiry <=12
Amber -> Months to Expiry >12 and <=24
Green -> Months to Expiry >24
Exactly what I was looking for, thanks. Mind you, being able to apply a format directly to a field based on a text value doesn't seem like it would be that difficult. It's certainly been something that I could do in Excel for years - come on Microsoft.
Perfect, thanks!
I had the same problem and this is what I did:
- Create a new column
- Create an IF formula based on your text column, make it take numbers instead of the values. For example, my text column contained "Yes" and "No". I used the formula New column = IF([Textcolumn]="Yes",1,0).
- Go to the Conditional formatting option and chose to conditional format based on another column, chose your newly created column.
- You can do this with the first two types of conditional formatting: by color scale and by rules.
why is it if i choose conditional formating based on another column it automaticly uses SUM but i do not want it to sum just take the value
As an alternative you can use a measure to retrieve the first value for conditional formatting instead of column aggregation.
First Value = FIRSTNONBLANK('Table'[Column 1],'Table'[Column 1])
The May Update added this functionality. Now, users can conditionally format text and date fields, as long as you choose a numeric value to format on.
The May Update includes the ability to condtionally format text fields, as long as you choose a numeric value to format on.
This idea is currently "Started":
Conditional formatting (cell highligh, font, etc) when comparing multiple fields
I've been needing this functionality for months now.
Thanks
Kevin
Hi @Anonymous,
Up to date, there is no way to change the background or font color of a table cell for a text. Please review the following feature requests and commont on them.
Conditional Formatting for Text
Better Conditional Formatting Tools
Best Regards,
Angelia
User | Count |
---|---|
122 | |
69 | |
67 | |
58 | |
52 |
User | Count |
---|---|
189 | |
96 | |
67 | |
63 | |
53 |