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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
paradika123
New Member

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

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

1 ACCEPTED SOLUTION
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

See my rolling months quick measure here:

 

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

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
iamprajot
Responsive Resident
Responsive Resident

=
AVERAGEX (
DATESINPERIOD (
TableName[DateColumn],
LASTDATE ( TableName[DateColumn] ),
-3,
MONTH
),
SUM[AmountColumn])
)

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 

quentin_vigne
Solution Sage
Solution Sage

Hi @paradika123

 

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

 

relativedate.PNG

 

- Quentin

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.