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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
dw700d
Post Patron
Post Patron

Calculate Current Year spend & Prior Year

I would like to create two measures that calculate the total spend for income tax  by current year and the total spend for income tax by prior year. I would like the measures to recognize the year we are currently in an update accordingly. So for example since we are  in 2022 the current year measure would calculate the sum of income tax spend in 2022 and the prior year measure would calculate the sum of income tax spend for 2021. When 2023 arrives the measures should recognize this and the current year measure should calculate tax spend for the year 2023 and the prior year measure should calculate tax spend for 2022. Can anyone help me with this?

 

 

TaxType                Year      Spend    
Income Tax202050
vendor tax202040
state tax202060
Other202070
Income Tax2021100
vendor tax202140
state tax202156
Other202190
Income Tax202220
vendor tax202210
state tax202220
Other202235
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@dw700d , Create separate year or date table and then try

//Only year vs Year, not a level below

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

 

 

If you want based today

 

This year Today =
var _min = today()
return
CALCULATE(sum('Table'[Sales]), FILTER('Date','Date'[Date] = year(today()) ) )

 

Last year Today =
var _min = today()
return
CALCULATE(sum('Table'[Sales]), FILTER('Date','Date'[Date] = year(today())-1  ) )

 

 

or

 

 

This year Today =
var _min = today()
return
CALCULATE(sum('Table'[Sales]), FILTER(all('Date'),'Date'[Date] = year(today()) ) )

 

Last year Today =
var _min = today()
return
CALCULATE(sum('Table'[Sales]), FILTER(all('Date'),'Date'[Date] = year(today())-1  ) )

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@dw700d , Create separate year or date table and then try

//Only year vs Year, not a level below

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

 

 

If you want based today

 

This year Today =
var _min = today()
return
CALCULATE(sum('Table'[Sales]), FILTER('Date','Date'[Date] = year(today()) ) )

 

Last year Today =
var _min = today()
return
CALCULATE(sum('Table'[Sales]), FILTER('Date','Date'[Date] = year(today())-1  ) )

 

 

or

 

 

This year Today =
var _min = today()
return
CALCULATE(sum('Table'[Sales]), FILTER(all('Date'),'Date'[Date] = year(today()) ) )

 

Last year Today =
var _min = today()
return
CALCULATE(sum('Table'[Sales]), FILTER(all('Date'),'Date'[Date] = year(today())-1  ) )

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.