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
tbobolz
Resolver I
Resolver I

Simple IF statement not working. Help please!!!

Hi All,

 

I have used this system to auto find the current fiscal year many times in the past; however, today I just can't figure out why it is not working! The column in the below pbix file, "IsMaxCFY", seems correct but it returns true (or "1") for everything. I think I have clean fields, proper formatting. Am I just too tired tonight? 

 

https://drive.google.com/open?id=1FaCac9Ll6HObZ9z3Qma-K11M8b_rW3zK

 

Thanks for any help you can offer.

 

Terry

 

1 ACCEPTED SOLUTION

DAX is a challenging language to learn.  It seems straight forward but it is like an onion - the more you peel back the layers, the more you find new layers.

 

Here is the formula you seek

IsMaxCFY = if('Registration - Export'[Fiscal Year]=MAX('Registration - Export'[Fiscal Year]),1,0)
 
The issue is complex and has to do with context transition.

 

There are lots of things I would recommend you do differently.  Perhaps work through the knowledge base on my website

https://exceleratorbi.com.au/knowledge-base/

 

Be sure to read the best practices https://exceleratorbi.com.au/best-practices-power-pivot-power-query-power-bi/

 

 


* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

In a calculated column formula (IsMaxCFY), you are referring to a measure (CFY).  Why are you doing so?  Please describe your question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

 

Thanks for the reply.  Measure CFY is meant to find the MAX year, which it does fine in the dataset. (2019)

 

Then column IsMaxCFY should compare CFY to my fiscal years field with an IF statement and return a "1" if it is 2019, and "0" if the year is anything other. 

 

I then use IsMaxCFY as a filter to set all dashboard elements to the current fiscal year, and with each new year, this will automatically update. This has worked in many other senarios, but for some reason, this thime it is not working.  I see Matt A has offered a solution too, that I have not yet applied. (Thanks Matt). But I am still curious why this method has failed me this time.

 

In addtional, I'll use the same method to find the previous year, current/previous month to build YOY YTD comparison that once I connect to a gateway file, everything is auto set to update and correct its self as the years and month change.

 

Thanks for you help.

 

Hi,

Why not just drag the FY to the Report filter section and select 2019.  All visuals across all pages would be filtered by 2019.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

True, however, when the data starts to include FY20, then the file would not automatcally update to the new year.

 

DAX is a challenging language to learn.  It seems straight forward but it is like an onion - the more you peel back the layers, the more you find new layers.

 

Here is the formula you seek

IsMaxCFY = if('Registration - Export'[Fiscal Year]=MAX('Registration - Export'[Fiscal Year]),1,0)
 
The issue is complex and has to do with context transition.

 

There are lots of things I would recommend you do differently.  Perhaps work through the knowledge base on my website

https://exceleratorbi.com.au/knowledge-base/

 

Be sure to read the best practices https://exceleratorbi.com.au/best-practices-power-pivot-power-query-power-bi/

 

 


* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Thanks Matt,

 

Yes, such a simplier solution, I appreciatet your time and I WILL read through knowledgebase to grow. 

 

Terry 

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.