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

Rolling average not working for all days after slicing clients

Hello!

I have created a measure to calculate the rolling average of the money flow from my company's funds over the last 30 days, it works beautifully, and the calculation is done for everyday. But the problem is that after slicing clients, the calculation is no longer done for every day, but only for the dates when that particular client had impact on the money flow. This reduces the usability of the rolling average chart, i only want the money flow to be sliced by client, not the dates in which the calculation is being done. Here is the code from my measure: 

m_MedMov 30 =

var first_date = CALCULATE(FIRSTDATE('d_Calendario'[Date]), FILTER(ALL('d_Calendario'), [money_flow] <> BLANK()))

var rolling_sum = CALCULATE([money_flow], DATESINPERIOD('d_Calendario'[Date], LASTDATE('d_Calendario'[Date]), - 30, DAY)

return

IF(SELECTEDVALUE('d_Calendario'[Date]) > first_date + 30 && SELECTEDVALUE('d_Calendario'[Date]) <= MAX('d_Calendario'[Date]), rolling_sum / 30, BLANK())

Can anyone please shed some light on wether there is a solution for this?

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Joey_ Try: Better Rolling Average - Microsoft Power BI Community


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks a lot for the suggestion, but that does not solve my problem. I need the rolling average to be calculated for every single day, regardless of data slicing.

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.