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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Text comparison in power Bi

test measure = SWITCH(TRUE() ,"9.9" >= "10.5" , "#00AA00" ,"9.9" < "9.5","#FF1E00", "#BFA416" )

 

For the above dax it will return #00AA00 which is not same as per number comparison  .How power bi compare text values?

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous,

 

In Power BI, it will compare one by one starting from the first character of the string.

For example, "9.9" vs "10.5", Power BI judges that they are strings. And the first character "9" of "9.9" is larger than the first character "1" of "10.5", so "9.9">"10.5" is true.

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Anonymous,

 

In Power BI, it will compare one by one starting from the first character of the string.

For example, "9.9" vs "10.5", Power BI judges that they are strings. And the first character "9" of "9.9" is larger than the first character "1" of "10.5", so "9.9">"10.5" is true.

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

amitchandak
Super User
Super User

@Anonymous , In double quote, it will be a string. Try like

test measure = SWITCH(TRUE() ,9.9 >= 10.5 , "#00AA00" ,9.9 < 9.5,"#FF1E00", "#BFA416" )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
ryan_mayu
Super User
Super User

@Anonymous 

maybe you can try this

test measure = SWITCH(TRUE() ,VALUE("9.9") >= value("10.5") , "#00AA00" ,value("9.9" )< value("9.5"),"#FF1E00", "#BFA416" )

1.PNG





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

Proud to be a Super User!




Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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