The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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...
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
20 | |
18 | |
16 | |
14 | |
13 |
User | Count |
---|---|
36 | |
35 | |
21 | |
19 | |
18 |