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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
WV
Frequent Visitor

DAX - IF Field Time Matches specific value

Hi,

I am trying to do an if statement in DAX. I want to say if the date is = 2018, then use this other calculation, else do another separate calculation. The data starts in 2018 and the rules change for every year after that. So I need one set of logic to sum the 2018 and another for everything after. I am doing this for Tax purposes and we always need a beginning balance to calculate down to an ending balance. Which will become the beginning balance the following year. 

 

Though the initial validation step in the if statement where I say "if time period equals 2018" it does not like the syntax. I can use the same exact syntax in a Calculate SUM formula - and the Year (xxxxxxx) ="2018" works fine.

 

What I am seeing is below. I call out the table and field, ask it to look at only the year, then validate. It works in one context but not the other.

 

WV_0-1662584564860.png

 

E&P Ending Balance =
IF(Year('Master_TB_FC Detail'[Time Period]) = 2018

// CALCULATE (
//     SUM ( 'Master_TB_FC Detail'[TB Amounts] ),
//     FILTER ( 'Master_TB_FC Detail', Year('Master_TB_FC Detail'[Time Period]) = 2018
// )))))))))

 

I have no idea why in the context of the If statement that is failing. The time period field is formatted as a date.

Any help here is greatly appreciated.

 

Thanks,

WV

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @WV ,

 

You need get one date value from the field first for year(). Try this:

 

IF(Year(max(Master_TB_FC Detail'[Time Period])) = 2018
 
 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-chenwuz-msft
Community Support
Community Support

Hi @WV ,

 

You need get one date value from the field first for year(). Try this:

 

IF(Year(max(Master_TB_FC Detail'[Time Period])) = 2018
 
 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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