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

Calculate balance of account

Hi,

I have data in two tables plus a separate date table.

1st table have all the opening balances of accounts 2013-07-01.

2nd table have all transactions of the accounts.

I want to calculate the montly balance of the accounts.

 

 

First I created:


Balance = SUM('BFO BR Transactions'[Amount]) + SUM('BFO Balance'[OpeningBalance])

 

And to calculate cummulative balance:

Cummulated balance = 
CALCULATE([Balance]; ALL('BFO BR Transactions'[Date]);
          DATESINPERIOD('Date'[Date]; 
                        LASTDATE('BFO BR Transactions'[Date]);-1000;MONTH
                       )
         )

 

This works as intended until I add a date slicer and I slice beyond a date where a account don't have any transactions.

For examle, one account have had the same balance since 2014-02-02 and therefore no transactions after this date. If I slice to see the balances for 2016 the end balance 2014-02-02 for the mentioned account is not in the sum.

 

What have I done wrong here?

 

1 ACCEPTED SOLUTION

Thank you for taking your time to help 🙂

 

I managed to solve this myself by change a filter from page filter to include it in the DAX formula.

 

Cummulated balance = CALCULATE(
CALCULATE(SUM('BFO BR Transactions'[Amount]);
FILTER('BFO BR Transactions';
'BFO BR Transactions'[Account] >= 1910
&& 'BFO BR Transactions'[Account] <= 1941))
+ CALCULATE(SUM('BFO Saldo'[Opening balance]);
FILTER('BFO Saldo';
'BFO Balance'[Account] >= 1910
&& 'BFO Balance'[Account] <= 1941)) ;ALL('BFO BR Transactions'[Date]); DATESINPERIOD('Date'[Date]; LASTDATE('BFO BR Transactions'[Date]);-1000;MONTH ) )

With this I get the correct balance at each month regardless of how I adjust my date slicer.

View solution in original post

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @Greger1337,

 

Would you please share your sample data to elaborate your scenario?

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for taking your time to help 🙂

 

I managed to solve this myself by change a filter from page filter to include it in the DAX formula.

 

Cummulated balance = CALCULATE(
CALCULATE(SUM('BFO BR Transactions'[Amount]);
FILTER('BFO BR Transactions';
'BFO BR Transactions'[Account] >= 1910
&& 'BFO BR Transactions'[Account] <= 1941))
+ CALCULATE(SUM('BFO Saldo'[Opening balance]);
FILTER('BFO Saldo';
'BFO Balance'[Account] >= 1910
&& 'BFO Balance'[Account] <= 1941)) ;ALL('BFO BR Transactions'[Date]); DATESINPERIOD('Date'[Date]; LASTDATE('BFO BR Transactions'[Date]);-1000;MONTH ) )

With this I get the correct balance at each month regardless of how I adjust my date slicer.

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.