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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
kwouter1
Frequent Visitor

Evaluate a text composed expression as DAX espression

I am trying to build a generic Red Amber Green evaluation
For simplicity reasons I limit the example to Red
I use following calculated column to put a "R" (from Red) in a field ( which I will later transalate to a hex Red color code and then based on this value use conditional color coding to color code my reports.
RED_TH=          0.9     ( red threshold)
RED_SIGN=       <   (operator I want to use)
 
RAG2 =
var RED_TH=LOOKUPVALUE(TARGETS[RAG_RED_TH],TARGETS[PLATFORM],MSR[PLATFORM],TARGETS[METRIC],MSR[Metric])
var RED_SIGN=LOOKUPVALUE(TARGETS[RAG_RED_SIGN],TARGETS[PLATFORM],MSR[PLATFORM],TARGETS[METRIC],MSR[Metric])

 

 
//below I construct the expression, pls notive that the field ACTUAL in table MSR where i create the formula is containing the actual result I want to evaluate versus target
 
var expressionRED="MSR[ACTUAL]" & RED_SIGN & RED_TH

//Above would result in MSR[ACTUAL]<0.9

return
//then try to evaluate the constructed expression as part of if statement
 
IF(expressionRED,"R","")
 
I always get the error "Cannot convert value '<0.9' of type Text to type True/False."
 
Hope anyone can help me to convert the constructed to a DAX expression. Thnx for help, Koen
 
3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @kwouter1 ,

 

Please follow the error message for troubleshooting "Cannot convert value '<0.9' of type Text to type True/False."

If the problem persists,could you share the sample pbix via cloud service like onedrive for business?

Please remove any sensitive data before uploading.

https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-... 

 

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

 

kwouter1
Frequent Visitor

Thank you sir, I indeed tried that but same result, if i levae the quote away rightfully the expression is there but still sees it as a text, but actually right quote should not be there. Thnx will need to continue to look

amitchandak
Super User
Super User

@kwouter1 , I think this should be without doublr quote

 

var expressionRED=MSR[ACTUAL] & RED_SIGN & RED_TH

 

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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
Top Kudoed Authors