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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
third_hicana
Helper IV
Helper IV

DAX for conditional formatting for font color

Hi Everyone. Asking for your help on conditional formatting for font color.

 

I want to highlight with red color if the 'Value' of each 'money_type' category of projects (those BOP IDs with suffix) and with 'BOP Tagging' equal to Project exceeds the budget of BOP.

 

For Example

 

 

For BOP25-018, it should highlight as red since BOP25-018-B with  capex, opex and total of 85, 20.50 , 105.50 respectively exceeds the budget of BOP25-018 with budget 65, 2 and 67 respectively.

 

While for project BOP25-035-B and BOP25-035-c should NOT be highlighted as red since the totals of these projects does not exceed  to the BOP budget of BOP25-035.

 

I tried this DAX but it also highlights the project budgets that does not exceed to the BOP budget.

VAR projects_tagging = SELECTEDVALUE('Projects Table'[BOP Tagging])
VAR moneyType = {"CAPEX", "OPEX", "TOTAL"}
RETURN
IF(
    projects_tagging = "Project" &&
    SELECTEDVALUE('Projects Table'[money_type])
    IN moneyType
    && 'Projects Table'[Project Refined Budget] > 'Projects Table'[BOP Refined Budget],
    "Red"
)
 
third_hicana_0-1727071753931.png

 

 

Here' the sample data. Thank you for your help

New BOP IDmoney_typeValueBOP Tagging
BOP25-035TOTAL£550.00BOP
BOP25-035CAPEX£350.00BOP
BOP25-035OPEX£200.00BOP
BOP25-018TOTAL£67.00BOP
BOP25-018CAPEX£65.00BOP
BOP25-018OPEX£2.00BOP
BOP25-035-BTOTAL£30.00Project
BOP25-035-BCAPEX£10.00Project
BOP25-035-BOPEX£20.00Project
BOP25-018-BTOTAL£105.50Project
BOP25-018-BCAPEX£85.00Project
BOP25-018-BOPEX£20.50Project
3 REPLIES 3
ValtteriN
Super User
Super User

Hi,

To troubleshoot you should add Projects Table'[Project Refined Budget] and 'Projects Table'[BOP Refined Budget] as variables. 

So,

var _BOP_B = SELECTEDVALUE('Projects Table'[BOP Refined Budget])
var _ P_B = SELECTEDVALUE('Projects Table'[Project Refined Budget]).

Now test your filter context like this:
BOP test 


VAR projects_tagging = SELECTEDVALUE('Projects Table'[BOP Tagging])
VAR moneyType = {"CAPEX", "OPEX", "TOTAL"}
var _BOP_B = SELECTEDVALUE('Projects Table'[BOP Refined Budget])
var _ P_B = SELECTEDVALUE('Projects Table'[Project Refined Budget]).

RETURN
/*
IF(
    projects_tagging = "Project" &&
    SELECTEDVALUE('Projects Table'[money_type])
    IN moneyType
    && 'Projects Table'[Project Refined Budget] > 'Projects Table'[BOP Refined Budget],
    "Red"
)
*/

_BOP_B


And the same for the other


 

VAR projects_tagging = SELECTEDVALUE('Projects Table'[BOP Tagging])
VAR moneyType = {"CAPEX", "OPEX", "TOTAL"}
var _BOP_B = SELECTEDVALUE('Projects Table'[BOP Refined Budget])
var _ P_B = SELECTEDVALUE('Projects Table'[Project Refined Budget]).

RETURN
/*
IF(
    projects_tagging = "Project" &&
    SELECTEDVALUE('Projects Table'[money_type])
    IN moneyType
    &&
_BOP_B

 >

_P_B

 

,
    "Red"
)
*/

_P_B

 


This way you can see if your calculation for the budgets is behaving as expected. Now if the values don't mathc your expetations. E.g. if BOP25-035 CAPEX is not 350. You can change the variable's calculation until the result is as expected.


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ValtteriN 
Thanks for your response. However, the 

'Projects Table'[BOP Refined Budget] and 'Projects Table'[Project Refined Budget] are measures in my table. Its does not work in SELECTED VALUE function on my end.

Hi,
In that case you can just test the measures the main point is to see if the measures are returning expected valeus to meet the IF conditions.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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