cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ShazaibShoukath
Regular Visitor

DAX query to colour front in red or green

HI guys, I want to change my font colour into green or red depending on dax formula so my ask is, campare asset number from table 1 with table 2, IF the assest number matchs then color the amount field to green else colour the amount as red (If it does'nt match), i want as dax formula for this 

1 ACCEPTED SOLUTION
ShazaibShoukath
Regular Visitor

got it, Please use this for ref , ##Font Color Measure =
IF(
COUNTROWS(
FILTER(
'table 1',
'table 1'[values] IN VALUES('table 2'[values])
)
) > 0,
"Green",
"Red"
)
##

then after this go to

1.In the "Visualizations" pane, select the table visual and go to the "Conditional formatting" section.

2.Choose the value or column that you want to format based on the measure. For example, if you want to format the "Value" column, select it. then select rules and give string value as green and change the color as green and so on for red too. 

 

please if you find it helpful like it.

View solution in original post

4 REPLIES 4
ShazaibShoukath
Regular Visitor

got it, Please use this for ref , ##Font Color Measure =
IF(
COUNTROWS(
FILTER(
'table 1',
'table 1'[values] IN VALUES('table 2'[values])
)
) > 0,
"Green",
"Red"
)
##

then after this go to

1.In the "Visualizations" pane, select the table visual and go to the "Conditional formatting" section.

2.Choose the value or column that you want to format based on the measure. For example, if you want to format the "Value" column, select it. then select rules and give string value as green and change the color as green and so on for red too. 

 

please if you find it helpful like it.

pratyashasamal
Solution Sage
Solution Sage

Hi @ShazaibShoukath ,
You can use this type of dax to change the font color dynamically .
For example :-

Measure Value Color = SWITCH(TRUE();
                               [Measure Value] <=1;"#000000";
                               [Measure Value] <99,5;"#e60000";
                               [Measure Value] <100,5;"#000000";
                               [Measure Value] <999999;"#2d862d";
                               "#000000"
                             )   

 You can also refer to these links :-
https://databear.com/changing-colours-using-dax-and-conditional-formatting-in-power-bi/

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...

Thanks ,
Pratyasha Samal
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

it working only when you have values inside singel table but i would like to compare the values or columns from 2 diffrent table and see the match, If match is found then give it as green else give as red.

How you are comparing.. which type of visual you are using.. can we have snap of your data model to understand it better

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors