March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I have been asked to prepare a table where values who surpass a threshold (180, 360, 900 or 1800) or equal to it are to be highlighted, as well as have any value less than 1800 to be represented as <1800 while still keeping empty blank cells blank.
From my understanding I need to use a IF funtcion to get that to work? Or would I need to also mention the empty cells? And how would that affect the IF function? As the data would be refreshed. Below is a table of how it should look like. How would the highlighting work as well? I also attached a screenshot of how the highlight should be like.
Treshold | Lab Result 1 | Lab Result 2 | Lab Result 3 | Lab Result 4 | Lab Result 5 | Lab Result 6 |
1800 | <1800 | 29000 | <1800 | 14000 | <1800 | <1800 |
360 | <360 | <360 | <360 | 2000 | <360 | <360 |
180 | 52000 | 7900 | 4600 | <180 | <180 | <180 |
900 | 35000 | 120000 | 74000 | 1100 | <900 | <900 |
- | - | - | - | - | - | - |
360 | 3300 | 600 | 1700 | 620 | <360 | <360 |
Solved! Go to Solution.
Hi @AmazingRandom ,
As per our understanding you have above mentioned data in your table and you want a way for applying background color based on your condition, then you need to create a custom column with below expression,
After applying same formatting to each column, this will result as below,
Thanks!
Inogic Professional Services Division
Power Platform and Microsoft Dynamics 365 CRM Development – All under one roof!
Drop an email at crm@inogic.com
Services: http://www.inogic.com/services/
Power Platform/Dynamics 365 CRM Tips and Tricks: http://www.inogic.com/blog/
May I ask if this is the expected output you are looking for? Based on your description, I made a visual as follows
Measures:
Measure1 =
VAR _r1 =
SELECTEDVALUE ( 'Table'[Lab Result 1] )
VAR _r0 =
SELECTEDVALUE ( 'Table'[Treshold] )
RETURN
SWITCH ( TRUE (), _r1 > _r0, _r1, _r1 < _r0, "<" & _r0 )
Measure2 =
VAR _r2 =
SELECTEDVALUE ( 'Table'[Lab Result 2] )
VAR _r0 =
SELECTEDVALUE ( 'Table'[Treshold] )
RETURN
SWITCH ( TRUE (), _r2 > _r0, _r2, _r2 < _r0, "<" & _r0 )
Measure3 =
VAR _r3 =
SELECTEDVALUE ( 'Table'[Lab Result 2] )
VAR _r0 =
SELECTEDVALUE ( 'Table'[Treshold] )
RETURN
SWITCH ( TRUE (), _r3 > _r0, _r3, _r3 < _r0, "<" & _r0 )
Measure4 =
VAR _r4 =
SELECTEDVALUE ( 'Table'[Lab Result 1] )
VAR _r0 =
SELECTEDVALUE ( 'Table'[Treshold] )
RETURN
SWITCH ( TRUE (), _r4 > _r0, _r4, _r4 < _r0, "<" & _r0 )
Measure5 =
VAR _r5 =
SELECTEDVALUE ( 'Table'[Lab Result 2] )
VAR _r0 =
SELECTEDVALUE ( 'Table'[Treshold] )
RETURN
SWITCH ( TRUE (), _r5 > _r0, _r5, _r5 < _r0, "<" & _r0 )
Measure6 =
VAR _r6 =
SELECTEDVALUE ( 'Table'[Lab Result 2] )
VAR _r0 =
SELECTEDVALUE ( 'Table'[Treshold] )
RETURN
SWITCH ( TRUE (), _r6 > _r0, _r6, _r6 < _r0, "<" & _r0 )
Set background:
All six columns of measure should have the same setting.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi! Thanks for your help, it seems to work but for some reason I'm getting all values formatted with the background colour, even with the condition being "does not contain <"
Hi @AmazingRandom ,
As per our understanding you have above mentioned data in your table and you want a way for applying background color based on your condition, then you need to create a custom column with below expression,
After applying same formatting to each column, this will result as below,
Thanks!
Inogic Professional Services Division
Power Platform and Microsoft Dynamics 365 CRM Development – All under one roof!
Drop an email at crm@inogic.com
Services: http://www.inogic.com/services/
Power Platform/Dynamics 365 CRM Tips and Tricks: http://www.inogic.com/blog/
Hi! Thanks for your help! One question in case the client, if they were to prefer blank values over the "-" how would I edit the formula? I tried doing that but to no success
Hi @AmazingRandom ,
For null values you can simply update expression as below,
Thanks!
Inogic Professional Services Division
Power Platform and Microsoft Dynamics 365 CRM Development – All under one roof!
Drop an email at crm@inogic.com
Services: http://www.inogic.com/services/
Power Platform/Dynamics 365 CRM Tips and Tricks: http://www.inogic.com/blog/
Create a New Column for Display:
Create a new column that displays the values based on the conditions you provided.
DisplayColumn =
IF([Lab Result 1] >= 1800, "<1800",
IF([Lab Result 1] >= 360, "<360",
IF([Lab Result 1] >= 180, "<180",
IF([Lab Result 1] >= 900, "<900", BLANK()))))
Repeat this for each Lab Result column.
Conditional Formatting Rules: Use conditional formatting rules to highlight cells based on their values.
For example, set the color scale to go from light green (lowest values) to dark green (highest values). This will visually represent the hierarchy of values.
Apply Conditional Formatting to All Relevant Columns: Apply the conditional formatting rules to all Lab Result columns.
Handle Blank Cells: To keep empty cells blank, you don't need to explicitly mention them in the IF statement. The BLANK() function will handle this for you. The conditional formatting rules will also work with blank cells.
Dynamic Data Refresh: If your data is refreshed, the DAX formulas will recalculate, and the conditional formatting rules will be reapplied automatically.
Here's a generic example for one column. You can adapt it for other columns:
DisplayColumnLabResult1 =
IF([Lab Result 1] >= 1800, "<1800",
IF([Lab Result 1] >= 360, "<360",
IF([Lab Result 1] >= 180, "<180",
IF([Lab Result 1] >= 900, "<900", BLANK()))))
Remember to adjust the column names and conditions according to your actual column names and requirements.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
18 | |
15 | |
9 | |
8 |
User | Count |
---|---|
37 | |
32 | |
18 | |
16 | |
13 |