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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MartyR
New Member

Rolling Average w/ Multiple Entries Per Date

Hi all.  Still very much a beginner at DAX so any help would be much appreciated.  I'm trying to get a rolling average of Product Distribution, but when I use the DAX codes I can find online for rolling averages, it creates an error as the date column contains duplicate dates.  The code I'm trying to use is;

 

Product X Rolling 4Wk =
VAR NumDays = 28
VAR RollingSum =
CALCULATE(
SUM('Raw Data'[Product X In Store?]),
DATESINPERIOD('Raw Data'[Call Date],LASTDATE('Raw Data'[Call Date]),-NumDays,DAY)
)
RETURN
RollingSum/NumDays

 

Example of type of data is as follows.  We show this as weekly average % distribution currently, but client has requested visibility of 4 week rolling average.

 

Call DateStore NameProduct X In Store?
06/09/21Store A1
06/09/21Store B0
06/09/21Store C0
07/09/21Store D1
07/09/21Store E1
07/09/21Store F1
08/09/21Store G0
08/09/21Store H1
08/09/21Store I0

 

Any help would be greatly appreciated!

2 REPLIES 2
MartyR
New Member

Thanks, and great to know it's doable.  Will give that a go!

Schmidtmayer
Helper I
Helper I

Just create a table with unique date values and establish a connection between your initial table and your newly created dates table. Then change your measure to the date column of the newly created dates table. You may use CALENDARAUTO function (DAX) - DAX | Microsoft Docs for that.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors