Forum Discussion
Previous Year average and 2 year average
Hello!
I'm stuck and it would be great if you Experts could help me.
I do have a measure which calculates the monthly rents. What I would need is a average bar for the last and the second to last year.
The measure to calculate the monthly rent for reference:
I managed to solve it my self, once I got inspired by amitchandak's solution. 🙂
Its
Average last year = CALCULATE(SUM('Erlöse'[Betrag])/12;PREVIOUSYEAR(Datumstabelle[Date]);'Erlöse'[Positionsart] IN { "Miete" } )
and
Average second to last year = CALCULATE(SUM('Erlöse'[Betrag])/12;PARALLELPERIOD(Datumstabelle[Date];-2;YEAR);'Erlöse'[Positionsart] IN { "Miete" } )
Simple as that... ^^
Thanks all
6 Replies
- v-kelly-msft
Community Support
Hi micsafdas ,
You need 2 measures as below:
Last 2 years average = CALCULATE(AVERAGE('Table'[Value]),FILTER(CALCULATETABLE(ALLSELECTED('Table'),ALL('Table'[Date])),'Table'[Date].[Year]=YEAR(MAX('Table'[Date]))-2))Previous year average = CALCULATE(AVERAGE('Table'[Value]),FILTER(CALCULATETABLE(ALLSELECTED('Table'),ALL('Table'[Date])),'Table'[Date].[Year]=YEAR(MAX('Table'[Date]))-1))Finally you will see :
For the related .pbix file,pls click here.
Best Regards,
Kelly - micsafdasFrequent Visitor
As I can't seem to be able to attach the graphic in the original post here what I am looking for.
- amitchandak
Super User
In case you have date dimension
Last YTD complete Sales = CALCULATE(Avergae(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31")) Last to last YTD complete Sales = CALCULATE(Avergae(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-2,Year)),"12/31"))To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin- amitchandak
Super User
If you want sum first at month level and the Average
Avergaex(summarize(CALCULATETABLE('Erlöse', DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"), 'Erlöse'[Positionsart] IN { "Miete" }) ,date[month-year],"_sum",SUM('Erlöse'[Betrag])),_sum)