Forum Discussion
Conditional Formatting Bug
Hey guys,
I have column in a table which is conditonally formated based on a column named "D_CurrentStatusLightsColor", this always worked, but suddenly, some of the fields are white instead of the three selected colors (Red, Orange, Green). Here you can see the problem:
There are only 3 different colorcodes in the column, so it shouldnt be a problem of empty values:
Does anyone have an idea why this happens or is this a Power Bi Bug?
Thanks for your help,
Cheers,
janik
This is not a bug, this is how Power BI works. Here is what is happening:
- Your margin field, for example, has no data. So you tell it to show items with no data. This is one reason I don't use fields for values in visuals. Always use explict measures. SUM(Table[Margins]) for example. Still returns blanks. I'll get to that.
- Your conditional formatting isn't formatting the current Status field based on the color field. It is formatting it based on the FIRST() value of the color field. But you have no data, so even if you show the items with no data, the measure Power BI using in the background is returning no records, so there is no FIRST(colorfield) returned.
- The fix is to use an explicit measure like the following:
New Margin = COALESCE( SUM('Table'[Margin]), 0)So if there is no margin, it returns zero. Then you get this table:
If you don't want zeros in your table, you need to use custom formatting for the measures to return a visual blank. Use this format:
#,##0;-#,##0;It is on the model view:
Then you get this table:
8 Replies
- amitchandakSuper User
Anonymous , hope there is no white space od special character that is causing that
- edhansCommunity Champion
Are you sure there are no trailing spaces or other issues with the text? This is not a bug. It is simply an issue with your data or how it is applies. A PBIX would be helpful to look at.
How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum - v-alq-msftCommunity Support
Hi, Anonymous
I don't think it is a bug. You may try to check if there is some extra space with the text. I'd like to suggest you use words to test if it works. I created data to reproduce your scenario.
Table:
'ID' is formatted by 'Color' and 'Color' is formatted by 'Color Text'. Here is the result. It appears normal.
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
I now added a new column:
Table.AddColumn(#"Removed Other Columns", "ColorCode", each if [D_CurrentStatusLightsColor] = "#70AD47" then "Green" else if [D_CurrentStatusLightsColor] = "#ED7D31" then "Orange" else if [D_CurrentStatusLightsColor] = "#FF0047" then "Red" else null)
This didnt give any mistakes or nulls (as would be the case with leading/trailing zeroes), thus the codes are correct. I get the same problem with the codes.
I tried to do a "if 1=1 then "Green""-column and this happened:
Same problem.
In the table, there are about 20 different column, and I figured out, that the formatting doesnt work whenever other column (in my case debt, margin and production) have no value.When I delete these rows, or when I changed the missing values (null) to 0, the problem vanishes and the current status fields are formatted again correctly.
This seems too random to not be a bug?
Any ideas?- edhansCommunity Champion
It isn't a bug Anonymous or a lot of people would have hit this. There is something else going on, but I'd need to see your PBIX file to really see what is going on. You can share it privately via PM if there is confidential data you don't want to expose by placing a link here in the forum.