Forum Discussion
current year- last year
Hi I need a dax function
I have a rank for month and year. if rank is 1 output is july 2025, by using rank 1 we need to show the percentage
so i need july 2025 - july 2024 percentage.
this is one senerio
and the other one is same but i need to show in bar visual for 3 years
rank 1 july2025-july2024
july 2024- july 2023
july 2023-july 2022 i need dax for this 2 i have tried multiple dax but getting blank values
- Anonymous1 year ago
i got the solution thank you
6 Replies
- alish_b
Super User
Hi Anonymous ,
I believe time based calculations with last and current period comparisons should be achievable. The presentation as you have described here could be tricky.
However, please share sample data (that can be easily copied) and also the desired outcome (just a simple sketch would be very helpful) so that others could build or guide you to a solution that actually works.Thanks!
- AnonymousNot applicable
i got the solution thank you
- alish_b
Super User
That is great Anonymous !
If you have the time, please share a synopsis of your approach so that anyone in the community facing that challenge now or in the future will find it helpful. I guess a moderator can then mark your approach as an accepted solution.
Cheers!
- Shahid12523
Community Champion
1️⃣YoY % for latest month (rank 1)
YoY % Latest Month =
VAR CurrentValue = CALCULATE(SUM('Table'[Value]), 'Table'[Rank] = 1)
VAR LastYearValue = CALCULATE(SUM('Table'[Value]), 'Table'[Rank] = 1, SAMEPERIODLASTYEAR('Table'[Date]))
RETURN DIVIDE(CurrentValue - LastYearValue, LastYearValue, 0)2️⃣YoY % for last 3 years in bar chart (rank 1 month only)
YoY % 3 Years =
VAR CurrentValue = CALCULATE(SUM('Table'[Value]), 'Table'[Rank] = 1)
VAR LastYearValue = CALCULATE(SUM('Table'[Value]), 'Table'[Rank] = 1, SAMEPERIODLASTYEAR('Table'[Date]))
RETURN DIVIDE(CurrentValue - LastYearValue, LastYearValue, 0)
Put Year on X-axis.Only rank 1 month is included (e.g., July).
If you want, I can make it auto-calculate the last 3 Julys for your bar chart, so you don’t need manual filters.