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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
pstrachn
Regular Visitor

Calculation based on current year

Hi,

 

I would like some help with an expression to calculate a variance based on checking which year we are currently in. I was thinking that an if statement could work here, but was not able to make this work yet.

I have the below express that currently calculates a forecast based on completed months. I'm running into an issue when the year flips over since there's no reference to year in my data. So what I've done is created a new column with value of 2022 to specify last year.

 

So I would like the below formula to run if we are in the current year. 

CapExYTDF = CALCULATE(SUM('F22 CapEx Data'[Budget Amount]), 'F22 CapEx Data'[Month Number] < month(today()))

 

If we are in anything other than the current year, I would like the below calculation to be used: 

CapExYTDF = CALCULATE(SUM('F22 CapEx Data'[Budget Amount])

3 REPLIES 3
Anonymous
Not applicable

Hi @pstrachn,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Hi,

 

Wanted to follow up and see if anyone had any suggestions on this? If there's anything other information i can provide, please let me know.

Thank you for your reply. Please see below dummy data structure.

 

1) So I would like the below formula to run if we are in the current year (as it relates to the Year column in table below. In this case the value in the year column is 2022, so the check would return a false result and should use the formula in step 2). 

CapExYTDF = CALCULATE(SUM('F22 CapEx Data'[Budget Amount]), 'F22 CapEx Data'[Month Number] < month(today()))

 

2) If we are in anything other than the current year (as it relates to the Year column in data below), I would like the below calculation to be used: 

CapExYTDF = CALCULATE(SUM('F22 CapEx Data'[Budget Amount])

 

 

DescriptionBudget AmountMonth NumberYear
Line Item 12500052022
Line Item 2200062022
Line Item 335000122022
Line Item 4100042022
Line Item 55600092022
Line Item 6500042022
Line Item 76300082022
Line Item 8652032022
Line Item 91562102022
Line Item 101655332022
Line Item 11986382022

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.