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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
MattAllington
Community Champion
Community Champion

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.
I will not give you bad advice, even if you unknowingly ask for it.

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.

 

MattAllington
Community Champion
Community Champion

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.
I will not give you bad advice, even if you unknowingly ask for it.

Thanks Matt,

 

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

 

Terry 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.