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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
igibson
Frequent Visitor

IF statement giving one result for all

I am using a statement to tell me whether not my goal was reached as follows: 

 

reachedgoal = if( divide([SalesAmt] - [Goal],[Goal]) >= 0, "Goal Reached", BLANK())

 

I am putting it into a table that shows the percent difference between salesamt and goal and these numbers go from negative to positive. However, all of the results for the reachedgoal come out as Goal Reached.  If I change the statement to > instead of >= they all show as blank. What am I doing incorrectly to yield these results and how can I fix it?

4 REPLIES 4
v-yulgu-msft
Employee
Employee

Hi @igibson,

 

If add a calculated column into data table, above formula can return expected results in my test. If create a measure to get results for reachedgoal, maybe you can try this:

reachedgoal measure =
IF (
    DIVIDE ( MAX ( [SalesAmt] ) - MAX ( [Goal] ), MAX ( [Goal] ) )
        >= 0,
    "Goal Reached",
    BLANK ()
)

For further advice, please provide sample data and screenshot of unexpected output you have got.

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Kyenslen
New Member

could you not just try

 

reachedgoal = if([SalesAmt] > [Goal], "Goal Reached", BLANK())

 

and have a seperate column for showing the percent margins?

 

 

 

igibson
Frequent Visitor

I am using a statement to tell me whether not my goal was reached as follows: 

 

reachedgoal = if( divide([SalesAmt] - [Goal],[Goal]) >= 0, "Goal Reached", BLANK())

 

I am putting it into a table that shows the percent difference between salesamt and goal and these numbers go drom negative to positive. All of the results for the reachedgoal come out as Goal Reached.  If I change the statement to > instead of >= they all show as blank.

Are you putting this formula into a custom column in your data model? I don't see how that formula would work as a measure without aggregation. This seems to work for me as a measure:

 

Measure 3 = IF(DIVIDE(SUM(Goals[SalesAmt]) - SUM(Goals[Goal]),SUM(Goals[Goal])) >=0,"Goal Reached",BLANK())

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors