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
bmturney
Frequent Visitor

Looking to calculate a 3 month rolling based on multiple filters

I have a set of data that looks something like this...

LocationDateVendorNameUnitsSoldTotalUnitsVendorShare
11/1/2021VendorA200100020%
21/1/2021VendorB300100030%
31/1/2021VendorC500100050%
12/1/2021VendorA25090027.78%
22/1/2021VendorB30090033.33%
32/1/2021VendorC45090050%
13/1/2021VendorA300120025%
23/1/2021VendorB600120050%
33/1/2021VendorC300120025%
14/1/2021VendorA400100040%

 

What I want to be able to do... is by location and by vendor, calculate a 3 month rolling average for the VendorShare.... so that if I'm looking at Location 1 > Vendor A>January the 3 month rolling average for Vendor Share would be 20%... but for February it would be 23.89%(AVERAGE(20%, 27.78%)) .. for March it would be 24.26% (AVERAGE(20%, 27.78%, 25%))... for April it would be 30.93% (AVERAGE(27.78%, 25%, 40%))... etc... 

 

if I PIVOT on VendorName I'm able to make it work by creating a measure using the AverageX function with a DATESINPERIOD filter... however, I would like to do this without having to do the PIVOT... because I would like to create a slicer that allows me to easily filter on VendorName... 

 

Any thoughts/suggestions would be greatly appreciated?

1 ACCEPTED SOLUTION
Krutigawale33
Responsive Resident
Responsive Resident

Hello @bmturney ,

 

try measure

rolling = CALCULATE(AVERAGE(Vendor[VendorShare]),ALLEXCEPT(Vendor,Vendor[VendorName],Vendor[Location]),
DATESINPERIOD(Vendor[Date],
LASTDATE(Vendor[Date]),-3, MONTH
))

Krutigawale33_0-1616473695647.png

 

 

View solution in original post

4 REPLIES 4
Krutigawale33
Responsive Resident
Responsive Resident

Hello @bmturney ,

 

try measure

rolling = CALCULATE(AVERAGE(Vendor[VendorShare]),ALLEXCEPT(Vendor,Vendor[VendorName],Vendor[Location]),
DATESINPERIOD(Vendor[Date],
LASTDATE(Vendor[Date]),-3, MONTH
))

Krutigawale33_0-1616473695647.png

 

 

Awesome... this worked perfectly for what I needed... if we were in the same room I would put my arm around your shoulders and rub my knuckles on top of your head (act of endearment here in the U.S.  ;^) )

Thanks @bmturney I am happy that solves your issue.

amitchandak
Super User
Super User

@bmturney , Try a measure like with help from date table

Rolling 3 = divide(CALCULATE(sum(Table[Unit Sold]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date]),-3,MONTH)) ,
CALCULATE(sum(Table[Unit Sold]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date]),-3,MONTH), filter(allselected(Table),Table[Location] = max(Table[Location]))))

 

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 :radacad sqlbi My Video Series Appreciate your Kudos.

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.