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

Calculate 7 days back for each date to have a smoother graph

Data looks like this(without 7 days moving), I want to create a measure that creates the 7 days moving which looks at every day and sums the past 7 days of data so I can get a smoother graph at the end. TIA!:

 

Marshy_0-1594308651086.png

Marshy_1-1594308729568.png

Marshy_3-1594308808590.png

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Marshy , You can have rolling 7 days avg like this

Rolling 7 day = CALCULATE(sum(Table[Number]),DATESINPERIOD('Date'[Date],MAX(Table[Date]),-7,Day))/7
or
Rolling 7 day = CALCULATE(sum(Table[Number])/distinctcount(Table[Date]),DATESINPERIOD('Date'[Date],MAX(Table[Date]),-7,Day))

 

View solution in original post

3 REPLIES 3
AntrikshSharma
Community Champion
Community Champion

Custom Running Total =
VAR TimeSpan = 7
VAR MaxVisibleDate =
    MAX ( Dates[Date] )
VAR ListOfDates =
    FILTER (
        ALL ( Dates ),
        Dates[Date] <= MaxVisibleDate
            && Dates[Date] > MaxVisibleDate - TimeSpan
    )
VAR Result =
    CALCULATE ( [Total Sales], ListOfDates )
RETURN
    Result
amitchandak
Super User
Super User

@Marshy , You can have rolling 7 days avg like this

Rolling 7 day = CALCULATE(sum(Table[Number]),DATESINPERIOD('Date'[Date],MAX(Table[Date]),-7,Day))/7
or
Rolling 7 day = CALCULATE(sum(Table[Number])/distinctcount(Table[Date]),DATESINPERIOD('Date'[Date],MAX(Table[Date]),-7,Day))

 

@amitchandak thanks but I don't fully understand. I don't want avg so assume I can just take out the divide.

 

what is the difference between

'Date'[Date]

 and

Table[Date]

 Thanks!

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.