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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
game1
Helper II
Helper II

Compare the Last 12 months compared to 12 months prior to that same period

I have Table[date], Table[salary]. I don't have any other table. 

1-I want to calculate the sum of salary for last 12 months from today(May 2023 to May 2024) 

2-Then, calculate the sum of salary for last 12 months of the fisrt measure (May 2022 to May 2023).

 

So, I would be able to compare the 2 measures. 

 

Thanks!

2 ACCEPTED SOLUTIONS

TRIXTERBINOOB
Regular Visitor

It depends,  @lbendlin gives you a good solution. But I would prefer to use something like this:

 

CALCULATE(SUM(Table[salary]),DATESBETWEEN(Table[date],DATE(2023,5,1),DATE(2024,4,30)))

 

and do very much the same with 2022 and 2023. this will have static values but (in my experience with data) could be very confusing for managers and people that the measure change through time.

 

Hope this was useful to you. And sorry for my grammar mistooks, I still learning english. 

 

Kind regards.

 

View solution in original post

4 REPLIES 4
TRIXTERBINOOB
Regular Visitor

It depends,  @lbendlin gives you a good solution. But I would prefer to use something like this:

 

CALCULATE(SUM(Table[salary]),DATESBETWEEN(Table[date],DATE(2023,5,1),DATE(2024,4,30)))

 

and do very much the same with 2022 and 2023. this will have static values but (in my experience with data) could be very confusing for managers and people that the measure change through time.

 

Hope this was useful to you. And sorry for my grammar mistooks, I still learning english. 

 

Kind regards.

 

lbendlin
Super User
Super User

sounds good. What have you tried and where are you stuck?

I have try this, but it is not working. 

 

Last12MonthsPrior =
VAR date1 = TODAY()
VAR result =
CALCULATE (
[Last12MonthsSalary],  
ALLSELECTED (),
'Table'[DATE] <= date1,
'Table'[DATE]
>= DATE ( YEAR (date1) - 1, MONTH (date1), DAY (date1) )
)
RETURN
result

lbendlin_0-1714748503230.png

see attached

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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