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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors