- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

# How to calculate using "latest 3 months data" even I add more data later

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-18-2018 02:20 AM

Hi, everyone

I am still new at Power BI, maybe my english is not that good, I hope you understand my question..

So, I have this dataset (link below) where it have data for 3 months, I have to calculate AVERAGE on my data, I use this :

Average = CALCULATE(AVERAGE(StokSiloAll[Stok Keluar]);StokSiloAll[PLANT]=2404;StokSiloAll[TYPE]="PPC")

Then I realize, if use that code, then when I add some data later, ex : 1 month data later, it will calculate AVERAGE for 4 months instead of 3 months like i wanted.

Please help me, what is the right code so it can calculate AVERAGE with latest 3 months data..

Thanks

Dataset link : https://goo.gl/qoZB29

Solved! Go to Solution.

Accepted Solutions

## Re: How to calculate using "latest 3 months data" even I add more data later

[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-21-2018 01:23 AM - edited 05-21-2018 01:24 AM

@paradika123,

You can create the following measure. Then create rolling average measure based on the sum of stok measure following the guide in this blog.

Sum of stok=CALCULATE(SUM(StokSiloAll[Stok Keluar]);StokSiloAll[PLANT]=2404;StokSiloAll[TYPE]="PPC")

Regards,

Lydia

All Replies

## Re: How to calculate using "latest 3 months data" even I add more data later

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-18-2018 02:53 AM

Hi @paradika123

You need to use the relative date filtering so that you don't have to include your month in your formula anymore :

- Quentin

## Re: How to calculate using "latest 3 months data" even I add more data later

[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-18-2018 03:34 AM - edited 05-18-2018 03:35 AM

=

AVERAGEX (

DATESINPERIOD (

TableName[DateColumn],

LASTDATE ( TableName[DateColumn] ),

-3,

MONTH

),

SUM[AmountColumn])

)

## Re: How to calculate using "latest 3 months data" even I add more data later

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-18-2018 05:29 AM

See my rolling months quick measure here:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Rolling-Months/m-p/391499

**Did I answer your question? Mark my post as a solution!**

Proud to be a Datanaut!

## Re: How to calculate using "latest 3 months data" even I add more data later

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-18-2018 08:03 AM

I'm interested with your solution but it still cant work properly in my case, can you help me by apply your code into mine (my code in my question above) ?

thanks

## Re: How to calculate using "latest 3 months data" even I add more data later

[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-21-2018 01:23 AM - edited 05-21-2018 01:24 AM

@paradika123,

You can create the following measure. Then create rolling average measure based on the sum of stok measure following the guide in this blog.

Sum of stok=CALCULATE(SUM(StokSiloAll[Stok Keluar]);StokSiloAll[PLANT]=2404;StokSiloAll[TYPE]="PPC")

Regards,

Lydia