cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

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

Accepted Solutions
Highlighted
Resolver III
Resolver III

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

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

Highlighted
Super User IV
Super User IV

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

@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.






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
Highlighted
Super User IV
Super User IV

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

@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.

 






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.





Highlighted
Helper V
Helper V

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

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!

Highlighted
Super User IV
Super User IV

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

@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

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helper V
Helper V

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

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!

Highlighted
Resolver III
Resolver III

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

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

Highlighted
Super User IV
Super User IV

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

@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.






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

Helpful resources

Announcements
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors