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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
bmauro
Frequent Visitor

Using Switch or IF statement with measure not providing expected results

Trying to create a simple measure that displays a comment for a value generated by a measure. The measure calculates a variance number from actual vs. goal. The variance measure is calculating correctly. However, when I try to use IF or Switch functions to show a text comment based on the variance measure's value (number <0 = "Hours are under goal"), the results delivered are not consistent. In some cases the results are as expected but in others there are not. The dashboard shows variances for different relative date periods (month-to-date, year-to-date).

 

The DAX code is noted below.

 

Hours_Goal_Comment = SWITCH(TRUE(),[Hours_vs_Goal]<0,"Hours under goal",[Hours_vs_Goal]>0,"Hours exceed goal")

There are other measures used to calculate the Hours_vs_Goal measure so not sure if these are causing the issue. Also tired IF statements and got the same results. Any thoughts on why this is happening would be very helpful.

2 REPLIES 2
bmauro
Frequent Visitor

Problem solved. Thanks.

Hi @bmauro,

 

If you share your solution here I think it will be help for others who faced the similar issues.

 

Regards,

XIaoxin sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.