cancel
Showing results for
Did you mean:
Frequent Visitor

## 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:

Rent actual =
CALCULATE(SUM('Erlöse'[Betrag]); 'Erlöse'[Positionsart] IN { "Miete" })

If you need anything else to answer the question, I'm happy to share.

1 ACCEPTED SOLUTION
Frequent Visitor

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 6
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 :

Best Regards,
Kelly

Frequent Visitor

As I can't seem to be able to attach the graphic in the original post here what I am looking for.

Super User IV

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://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

Proud to be a Super User!

Frequent Visitor

Thanks for your post! This seems promising, but I didn't get the expected result back.

I probably explained it not to the fully extent.

I need (looking from 2019) the average of 2018, namely from 01.01.18 - 31.12.18 and from 2017 (vice versa)

No year to date calculations.

Btw, I do have a date table. To give it some "flesh", I uploaded the basic pbix which translates to the big pbix.

https://www.dropbox.com/s/u4wmq7puu5mzl05/Showcase.pbix?dl=0

I would expect the "Previous Year Average" to be at 4333 in 2018, as the sum of 2017 is 52K.

Thanks also!

I couldn't get your code to work though. It doesn't seem to understand this part:

Datumstabelle[Date].[Year]

The [Year] seems to be the problem. Why so?

Thanks so far you two!

Frequent Visitor

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

Super User IV

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)``````

Proud to be a Super User!

Announcements