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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
khampton
Frequent Visitor

Conditional Formatting based on field value not working with SQL database

I have been using conditional formatting on the background colour of the Cell Elements area to colour in all cells for a given segment of a matrix. Done in the visualisations pane, not DAX.

The formatting is based on a field in the data which has the colour hex code and it has worked perfectly as shown below:

khampton_3-1707236485908.png

 

The issue I'm having is when I use the exact same data but as a direct query from a SQL database instead of pasting into excel, I seem to have the below strange result where if both columns are blank, it does not apply the formatting. If I view the data point of the white cell in a table, it shows the correct colour hex code. This also works fine if one of the Amount or Value Fields is populated and the other is blank but for some reason when both are blank, it shows white.

khampton_4-1707236541246.png

The raw data is below and as mentioned, works absolutely fine from excel (pasted from the SQL result) or by entering data into power BI. The only time I have the issue is when the data source is the SQL dB. Any ideas?

 

khampton_5-1707236712792.png

 

4 REPLIES 4
Anonymous
Not applicable

Hi @khampton ,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

I don't have the option to attache a pbix file but the data is below if you're able to replicate the two scenarios.

I created a test file with one data source pasted directly into 'enter data' and for the other data source I created a dummy database table with the same data below, again the matrix does not colour double null fields when the data source is the database.

khampton_0-1707317227239.png

 

 

ProductAccountFieldAmountValueCell Colour
Product AABC Test1  #FFC107
Product AABC Test220000 #FFC107
Product AABC Test3 Text#FFC107
Product BABC Test1 Text#FFC107
Product BABC Test215000 #FFC107
Product BABC Test3 Text#FFC107

 

Anonymous
Not applicable

HI @khampton,

I suppose these blank parts are not existed correspond records in your table records, right? If that is the case, you can't use Dax expression to check and locate the specific row/ column combo due to the records not existed.
For this scenario, I'd like to suggest you create two unconnected tables with all row/column field values and use their field on matrix to replace original table fields as group.
After these steps, you can create a measure expression to extract the current category field value and use them as condition to lookup row table records, and setting default result if can't find correspond records on that table.

Using the SELECTEDVALUE function in DAX - SQLBI

Regards,

Xiaoxin Sheng

These fields don't have values but do need to be yellow. There is a default Cell Colour which is white when all 3 fields of a product are blank which also works correctly in the data, therefore I cannot set another default for the blank yellow calls to be yellow. I'm just confused why this works perfectly from an excel spreadsheet of the same data. I am not using DAX currently, I'm using the below conditional formatting:

Both of the above matrices use the exact same data and the exact same conditions, it's just the data source which is different.

 

khampton_0-1707383517811.png

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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