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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
DA12345
Frequent Visitor

Cumulative Total Between Two Columns Where The First Set to Zero

Good Day, I have a situation that is illustrated by the table below:

Date (Calendar Table)Customer NameOpening BalanceInvoice TotSubsClosing Balance
July 1, 2019A01002080
July 2, 2019A(closing balance goes here)20595

 

The idea is for the closing balance to become the opening balance at the start of each new day and continue on cumulatively. I have trouble ensuring that if this is the first day the customer is participating, the customer's opening balance is set to 0 and the closing balance keeps doing its thing onward. 

Any suggestions?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@DA12345 , Try measure like

 

Opening balanace = calculate(sum(Table[Invoice]) - sum(Table[TotSubs]) , filter(allselected('Date'), Date[Date] < max(Date[Date])))


Closing Balance = calculate(sum(Table[Invoice]) - sum(Table[TotSubs]) , filter(allselected('Date'), Date[Date] <= max(Date[Date])))

 

if closing balance is already a column  with number

 

 

Opening balanace

= CALCULATE(SUM(Table[closing balance ]),previousday('Date'[Date]))

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@DA12345 , Try measure like

 

Opening balanace = calculate(sum(Table[Invoice]) - sum(Table[TotSubs]) , filter(allselected('Date'), Date[Date] < max(Date[Date])))


Closing Balance = calculate(sum(Table[Invoice]) - sum(Table[TotSubs]) , filter(allselected('Date'), Date[Date] <= max(Date[Date])))

 

if closing balance is already a column  with number

 

 

Opening balanace

= CALCULATE(SUM(Table[closing balance ]),previousday('Date'[Date]))

Thank you. This works to a limited degree however, I have a date slider on the page that influences that table, if the earliest date range is not selected in that range, It doesn't present a correct closing balance based on what come before.

In my case, this I replaced ALLSELECTED() with ALL()

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.