The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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!
Solved! Go to Solution.
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.
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.
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
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
56 | |
32 | |
20 | |
17 | |
15 |
User | Count |
---|---|
53 | |
31 | |
30 | |
23 | |
21 |