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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
jeffwash666
New Member

Rolling average with multiple tanks

My data looks like this:

 

Tank

Date

Level

Tank 1

8/3/2024

1

Tank 1

8/4/2024

2

Tank 1

8/5/2024

1

Tank 2

8/3/2024

10

Tank 2

8/4/2024

15

Tank 2

8/5/2024

12

 

I need to create a “table” in Power BI that looks like this:

 

Tank

Date

Level

Rolling 7 day average

Tank 1

8/3/2024

1

Averages the level from 7/27 to 8/3 just for Tank 1

Tank 1

8/4/2024

2

Averages the level from 7/28 to 8/4 just for Tank 1

Tank 1

8/5/2024

1

Averages the level from 7/29 to 8/5 just for Tank 1

Tank 2

8/3/2024

10

Averages the level from 7/27 to 8/3 just for Tank 2

Tank 2

8/4/2024

15

Averages the level from 7/28 to 8/4 just for Tank 2

Tank 2

8/5/2024

12

Averages the level from 7/29 to 8/5 just for Tank 2

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jeffwash666 ,

I create a table as you mentioned.

vyilongmsft_0-1722922767153.png

Then I create a calculated column and here is the DAX code.

Rolling7DayAvg =
CALCULATE (
    AVERAGE ( 'Table'[Level] ),
    DATESINPERIOD ( 'Table'[Date], 'Table'[Date], -7, DAY ),
    ALLEXCEPT ( 'Table', 'Table'[Tank] )
)

Finally you will get what you want.

vyilongmsft_1-1722922881983.png

 

 

 

Best Regards

Yilong Zhou

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

3 REPLIES 3
Anonymous
Not applicable

Hi @jeffwash666 ,

I create a table as you mentioned.

vyilongmsft_0-1722922767153.png

Then I create a calculated column and here is the DAX code.

Rolling7DayAvg =
CALCULATE (
    AVERAGE ( 'Table'[Level] ),
    DATESINPERIOD ( 'Table'[Date], 'Table'[Date], -7, DAY ),
    ALLEXCEPT ( 'Table', 'Table'[Tank] )
)

Finally you will get what you want.

vyilongmsft_1-1722922881983.png

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Brilliant,  thanks so much!!

AmiraBedh
Super User
Super User

Create a CC :

Rolling 7 Day Average = 
VAR CurrentTank = 'MyData'[Tank]
VAR CurrentDate = 'MyData'[Date]
RETURN
CALCULATE(
    AVERAGE('MyData'[Level]),
    FILTER(
        'MyData',
        'MyData'[Tank] = CurrentTank &&
        'MyData'[Date] <= CurrentDate &&
        'MyData'[Date] >= CurrentDate - 6
    )
)

 

AmiraBedh_0-1722879365835.png

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors