cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
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 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.

Highlighted
Super User IV
Super User IV

Re: IF statement giving one result for all

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())

---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




Highlighted
New Member

Re: IF statement giving one result for all

could you not just try

 

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

 

and have a seperate column for showing the percent margins?

 

 

 

Highlighted
Microsoft
Microsoft

Re: IF statement giving one result for all

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.

Helpful resources

Announcements
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Top Solution Authors