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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MHein17
Frequent Visitor

Rolling Total across different weeks

Rolling Totals.png

I have 4 columns that interact with each other: Total Actual Occupied Units, Total Projected Move-Ins, Total Projected Move-Outs and Total Project Occupied Units. Below is the DAX for each:

 

Total Actual Occupied Units:=CALCULATE(DISTINCTCOUNT(Units[UnitID]),FILTER(Units,Units[Flag] = "Yes"))

Total Projected Move-Ins:= CALCULATE(DISTINCTCOUNT(Proj[Unit ID]), FILTER(Proj,Proj[Flag] = "Move-In"))

Total Projected Move-Outs:= CALCULATE(DISTINCTCOUNT(Proj[Unit ID]), FILTER(Proj,Proj[Flag] = "Move-Out"))

Total Projected Occupied Units:= [Total Actual Occupied Units] + [Total Projected Move-Ins] - [Total Projected Move-Outs]

 

Currently For 3/17/2024, there are 5,062 occupied units + 4 Move-Ins - 12 Move-Outs = 5,054 projected occupied units. For 3/24/2024, I would like the 5,054 projected occupied units from the first week to carry over as the Actual Occupied Units (This will be renamed). So for week 3/24/2024, the math should work out to be 5,054 occupied units (from the first week 3/17/2024) + 8 Move-Ins - 16 Move Outs = 5,046, instead of it showing 5,054. Any help is greatly appreciated!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MHein17 , for such cases we use cumulative measures

 

example with date table used in measure, visual and filter

[Total Actual Occupied Units] + calculate( [Total Projected Move-Ins] - [Total Projected Move-Outs], filter(all(Date), Date[Date] <= Max(date[Date]) ) )

 

or

 

 calculate([Total Actual Occupied Units]+ [Total Projected Move-Ins] - [Total Projected Move-Outs], filter(all(Date), Date[Date] <= Max(date[Date]) ) )

 

Same as inventory onhand calculation

 

Power BI Inventory On Hand: https://youtu.be/nKbJ9Cpb-Aw

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@MHein17 , for such cases we use cumulative measures

 

example with date table used in measure, visual and filter

[Total Actual Occupied Units] + calculate( [Total Projected Move-Ins] - [Total Projected Move-Outs], filter(all(Date), Date[Date] <= Max(date[Date]) ) )

 

or

 

 calculate([Total Actual Occupied Units]+ [Total Projected Move-Ins] - [Total Projected Move-Outs], filter(all(Date), Date[Date] <= Max(date[Date]) ) )

 

Same as inventory onhand calculation

 

Power BI Inventory On Hand: https://youtu.be/nKbJ9Cpb-Aw

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Thank you for this. What if there are weeks where there is no Move Ins or Move Outs? These weeks revert back to the first week value

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.