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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
WaelTalaat79
Helper I
Helper I

Color Text

Dears,
i have this DAX formula and it shows as text because it contains % and Value in the same column

I need to color in read the text in negative

 

Margin Gap =
Var _MarginPercent = (DIVIDE([Margin Value],SUM('Sales'[Tot Sales])))
Var _MarginContract = MAX('Contract details'[Margin %])
Var _Marginvalue = (SUM('Sales'[Tot Sales]))-(SUM('Value'[Purchases]))
Var _MarginQTY = (_Marginvalue)/SUM('Value'[Invoice Qty])
VAR _Supplier = MAX('Value'[Supp.# & Name])
return
((IFERROR((IF(_Supplier="5927 MAHMOOD MALLIK INTERNATIONAL G.T", ((_MarginQTY)-(_MarginContract)),IF(_Supplier="6784 JUST FRIENDS CATERING SERVICES", ((_MarginQTY)-(_MarginContract)), FORMAT((_MarginPercent- _MarginContract), "0.##%")))),0)))WaelTalaat79_0-1700561899762.png

 

 
WaelTalaat79_1-1700561904220.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @WaelTalaat79 

You can create a measure to format.

Format = IF(CONTAINSSTRING([Margin Gap],"-"),"red","green")

Then put it to the conditional formatting of the [Margin Gap] measure, select font color.

vxinruzhumsft_0-1700704423800.png

Then set the condition.

vxinruzhumsft_1-1700704465243.png

Output

vxinruzhumsft_2-1700704477781.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
WaelTalaat79
Helper I
Helper I

Thanks

Anonymous
Not applicable

Hi @WaelTalaat79 

You can create a measure to format.

Format = IF(CONTAINSSTRING([Margin Gap],"-"),"red","green")

Then put it to the conditional formatting of the [Margin Gap] measure, select font color.

vxinruzhumsft_0-1700704423800.png

Then set the condition.

vxinruzhumsft_1-1700704465243.png

Output

vxinruzhumsft_2-1700704477781.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.