Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello experts,
The following question must be simple to answer, but I fail in getting the answer, so please guide me into the correct direction.
I am building a financial dashboard, P&L, Balance, Cashflow etc.
As input I have a transaction table, and report layout and date based on month selection (Starting balanse 31-12-yyyy is value 00, month Jan = 01 etc.
Calculating the Balance is done using DAX by summing the indiviual Ledgers and that is working fine. However I end up with the month delta values (the change in the balance) while I need to add the starting balance (for January), add (starting balance + January delta) for february etc. But I fail to do something simple of adding the value of previous column to my current value.
On Internet I find all kinds of DAX examples, like the following:
Balance rolling=
VAR cmonth = CALCULATE(VALUES('Date'[Date]))
VAR pmonth = CALCULATE(VALUES('Date'[Date]), PREVIOUSMONTH(Date[Date]))
VAR stapshotactualcmonth = CALCULATE([Balance Total], all('Date'), 'Date'[Date] = cmonth)
VAR stapshotactualpmonth = CALCULATE([Balance Total], all('Date'), 'Date'[Date] = pmonth)
RETURN (stapshotactualcmonth + stapshotactualpmonth)
The DAX for coming to these financials is:
//Sum of the transactions times a negative sign corrector
Balans SUM = SUM(Transacties[Transactie]) * [Balans Operator]
//Sum of the ledger range values
Balans Subtotaal =
VAR CurrentFrom = SELECTEDVALUE('Balance_Report'[FROM])
VAR CurrentTo = SELECTEDVALUE('Balance_Report'[TO])
Return
CALCULATE(
[Balans SUM],
FILTER(
ALL('Ledger_Mapping'),
'Ledger_Mapping'[Primary_Key] >= CurrentFrom &&
'Leger_Mapping'[Primary_Key] <= CurrentTo
)
)
// Values shown in the table
Balance Total = COALESCE([Balans SUM], [Balans Subtotaal])
Solved! Go to Solution.
Hello Muhammad10,
After playing with your setup, I found a working solution.
For the cmonth and pmonth, it works when I use the month field i.s.o date field (selecting 1 date vs an entire month)
Thanks for your help!!
Nice Bro sorry I was not able to reply early since I was out for a day glad you work on the solution always available
Regards
Hello Muhammad110,
After a closer look, there is still an issue...
It seems to do the calculation nicely for the first 2 column (time period), It is summing the values. But for the 3rd time period, it takes the last to column values i.s.o. the last 3 values etc.
So see below, the Balans SUM = SUM('Transactions'[Value]) table.
For Crediteuren, a value of 9600 in Jan, 4800 in Feb, 9600 in March etc.
When I apply the formula:
Hello,
Please show some demo data alongwth the desired output.
Thanks!!
It seems like you are trying to calculate the financial balance from transactions and display the delta values for each month. So you need to show the cumulative totals by adding the previous balance to the current value.
Balance rolling =
VAR cmonth = CALCULATE(MAX('Date'[Date]))
VAR pmonth = CALCULATE(MAX('Date'[Date]), PREVIOUSMONTH('Date'[Date]))
VAR stapshotactualcmonth = CALCULATE([Balance Total], 'Date'[Date] = cmonth)
VAR stapshotactualpmonth = CALCULATE([Balance Total], 'Date'[Date] = pmonth)
RETURN stapshotactualcmonth + IF(ISBLANK(stapshotactualpmonth), 0, stapshotactualpmonth)
Hello Muhammad10,
After playing with your setup, I found a working solution.
For the cmonth and pmonth, it works when I use the month field i.s.o date field (selecting 1 date vs an entire month)
Thanks for your help!!
Thanks Muhammad10,
When I use your formula, I get only values for the first column (Opening balance), and values for stapshotactualcmonth. The stapshotactualpmonth remain 0. So somethings is not right yet...
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
21 | |
21 | |
19 | |
13 | |
12 |
User | Count |
---|---|
42 | |
28 | |
23 | |
22 | |
22 |