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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Gjakova
Post Patron
Post Patron

How to calculate last year's score without using a date table?

Hi there,

I'm doing a report where I don't have a date calendar. So I can't use TI functions like SAMEPERIODLASTYEAR or DATEADD, because the only thing that is relevant in my data are the seasons e.g. season 2002/2003, 2003/2004 ..... 2020/2021

In this scenario, when creating a KPI, how can I create a measure that changes dynamically based on the filters that I select? So when I filter on 2018/2019.

My KPI shows that year + previous year (2017/2018). When I select 2006/2007, my KPI shows that year + previous year (2005/2006).

Someone who has an idea?

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Gjakova 

 

Try this measure.

 

Current+PrevYear = 
VAR selectedYearKey = SELECTEDVALUE(Years[Year_KEY])//Decide how will you handle no selection and mutiple selection
VAR PrevYearKey = selectedYearKey - 1
Return SUMX(
    FILTER(ALL(Scores), Scores[Year_KEY] in {selectedYearKey, PrevYearKey})
    , Scores[Score])

 

Hope this helps.

 

Please mark it as a solution if it serves the purpose.

 

Thanks

 

 

 

View solution in original post

@Gjakova solution attached

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Gjakova 

 

Try this measure.

 

Current+PrevYear = 
VAR selectedYearKey = SELECTEDVALUE(Years[Year_KEY])//Decide how will you handle no selection and mutiple selection
VAR PrevYearKey = selectedYearKey - 1
Return SUMX(
    FILTER(ALL(Scores), Scores[Year_KEY] in {selectedYearKey, PrevYearKey})
    , Scores[Score])

 

Hope this helps.

 

Please mark it as a solution if it serves the purpose.

 

Thanks

 

 

 

amitchandak
Super User
Super User

@Gjakova , Prefer to have separate Year table atleast , Try to use numeric year or rank to get that.

 

With date/year table

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

 

check option of without using time intelligence

Power BI — YTD Questions — Time Intelligence 1–5
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@Gjakova solution attached

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @amitchandak, unfortunalety I can't work with date tables. I also don't work with full years, but with seasons. So season 2017/2018 etc. 

If you have time, could you perhaps try your method out with my sample data? I tried it, but I can't get it to work. Hope to hear from you!

parry2k
Super User
Super User

@Gjakova if you have number field that identifies the order of the year, you can achieve this using following measure

 

 

 

Previous Year = 
VAR __id = MAX ( TableYear[Id] ) 
VAR __prevId = __id - 1
RETURN
CALCULATE ( SUM ( Table[Amount] ), TableYear[Id] = __prevId )

 

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I tried your answer, but it partly works @parry2k 
When I put my measure in a table and also the years, than it only shows the total previous, but the years stay blank.

Could you perhaps try it out with my sample data and see if you manage to make it work? If it works then I can replicate that same trick on my real dataset. Many thanks in advance!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors