March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi ,
I have given below sample input tables
This is NetCashFlow table which is a calculated table
Company | Month | Value |
A | Oct-24 | 10 |
A | Nov-24 | 10 |
A | Dec-24 | 10 |
A | Jan-25 | 10 |
A | Feb-25 | 10 |
A | Mar-25 | 10 |
A | Apr-25 | 10 |
A | May-25 | 10 |
A | Jun-25 | 10 |
A | Jul-25 | 10 |
A | Aug-25 | 10 |
A | Sep-25 | 10 |
A | Oct-25 | 10 |
A | Nov-25 | 10 |
A | Dec-25 | 10 |
B | Oct-24 | 10 |
B | Nov-24 | 10 |
B | Dec-24 | 10 |
B | Jan-25 | 10 |
B | Feb-25 | 10 |
B | Mar-25 | 10 |
B | Apr-25 | 10 |
B | May-25 | 10 |
B | Jun-25 | 10 |
B | Jul-25 | 10 |
B | Aug-25 | 10 |
B | Sep-25 | 10 |
B | Oct-25 | 10 |
B | Nov-25 | 10 |
B | Dec-25 | 10 |
This is Opening balance table
Company | Month | Value |
A | Oct-24 | 10 |
A | Nov-24 | 0 |
A | Dec-24 | 0 |
A | Jan-25 | 0 |
A | Feb-25 | 0 |
A | Mar-25 | 0 |
A | Apr-25 | 0 |
A | May-25 | 0 |
A | Jun-25 | 0 |
A | Jul-25 | 0 |
A | Aug-25 | 0 |
A | Sep-25 | 0 |
A | Oct-25 | 0 |
A | Nov-25 | 0 |
A | Dec-25 | 0 |
B | Oct-24 | 10 |
B | Nov-24 | 0 |
B | Dec-24 | 0 |
B | Jan-25 | 0 |
B | Feb-25 | 0 |
B | Mar-25 | 0 |
B | Apr-25 | 0 |
B | May-25 | 0 |
B | Jun-25 | 0 |
B | Jul-25 | 0 |
B | Aug-25 | 0 |
B | Sep-25 | 0 |
B | Oct-25 | 0 |
B | Nov-25 | 0 |
B | Dec-25 | 0 |
In this table months are dynamically getting populated using my calendar table, wherein it has months from Current month + remaining months of the current year + next year all the months.
In my original table, I have multiple company names in NetcashFlow and openingbalance tables.
Closing balance report should include companies from both the tables, for current month, it has value in net cashflow and opening balance tables, we can sum it up directly. CB = OB + NetCashFlow.
from next month onwards, Nov CB= OCT CB + Nov Netcashflow
Dec CB= Nov CB + Dec Netcashflow , This logic continues until the last month.
Sample output should contain company, Monthyear, closing balance
Could anyone suggest a DAX code for this ? Thanks in Advance.
Solved! Go to Solution.
Your current output seems confusing to me 🤔. Specifically, I don’t understand how Company B’s opening balance of 10 in October 2024 results in a cumulative (closing) balance of 170 for the same period, given that the Net Cash Flow for the month is only 10. Logically, the closing balance should be 20 for Company B, based on the company-level dimension.
To address this, I recommend creating two dimension tables—one for the calendar and another for the company—and establishing relationships between these dimensions and your opening balance and Net Cash Flow fact tables, as outlined below:
I would then create a cumulative measure for the closing balance using both the NetCashFlow and Opening Balance, as shown below:
Closing Balance =
VAR CurrentDate = MAX('Calendar'[Date])
RETURN
CALCULATE(
SUM(NetCashFlow[Value])+sum('Opening balance'[Value]),
FILTER(
ALL('Calendar'),
'Calendar'[Date] <= CurrentDate
)
)
The resulting output looks like below which differs from your expected output:
From an accounting perspective, the cumulative cash balance is calculated over time. However, your output appears to accumulate across the row index, which may not reflect standard accounting practices.
I have attached an example pbix file.
Best regards,
Hi Guys @lbendlin @v-mengmli-msft
I have found a DAX code for this. But there is some issue here. This code works perfectly to calculate closing balance for current month. It is trying to fetch current month closing balance to calculate Nov , dec and all other month's. It is failing to add CurrentClosingBalance with NextMonthNetCashFlow.
There is some issue in Return statement. It is checking if month is oct, then returning current month closing balance else it is returning
has to happen iteratively till the end of all other months
I am providing the code which i have written. PLease suggest me a code if you find a solution for this issue, It would be a great help.
Hi Guys,
Is anyone found any solution for this issue ? I am trying out many solutions but nothing works out.
Hi @GokilaRaviraj ,
Based on the data you provided, I think you need to create custom columns. Custom columns are used to determine the values used for accumulation. Here are my tests and pbix files for your reference.
Best regards,
Mengmeng Li
Thanks for your solution.
In my original input table, I have many company names.
How do I write a code for Comapny ID ?
Hi @GokilaRaviraj ,
The reason for sorting companies is that you expect the CB value for October of company B in the result to be 170 instead of 180. I treat it as monthly cumulative value determined by both the date and the company, only companies (A) whose date is the current month and whose order is 1 use this rule: CB = OB + NetCashFlow.
If I understand correctly, you should have a table for company sorting, if not, you need to create a company sorting table, you can use DISTINCT to get all the companies and then create a row sequence using the SWITCH function.
Best regards,
Mengmeng Li
Please show the expected outcome based on the sample data you provided.
Hi @lbendlin
Here is the expected ouput
Closing Balance | ||
Company | Month | Value |
A | Oct-24 | 20 |
A | Nov-24 | 30 |
A | Dec-24 | 40 |
A | Jan-25 | 50 |
A | Feb-25 | 60 |
A | Mar-25 | 70 |
A | Apr-25 | 80 |
A | May-25 | 90 |
A | Jun-25 | 100 |
A | Jul-25 | 110 |
A | Aug-25 | 120 |
A | Sep-25 | 130 |
A | Oct-25 | 140 |
A | Nov-25 | 150 |
A | Dec-25 | 160 |
B | Oct-24 | 170 |
B | Nov-24 | 180 |
B | Dec-24 | 190 |
B | Jan-25 | 200 |
B | Feb-25 | 210 |
B | Mar-25 | 220 |
B | Apr-25 | 230 |
B | May-25 | 240 |
B | Jun-25 | 250 |
B | Jul-25 | 260 |
B | Aug-25 | 270 |
B | Sep-25 | 280 |
B | Oct-25 | 290 |
B | Nov-25 | 300 |
B | Dec-25 | 310 |
Your current output seems confusing to me 🤔. Specifically, I don’t understand how Company B’s opening balance of 10 in October 2024 results in a cumulative (closing) balance of 170 for the same period, given that the Net Cash Flow for the month is only 10. Logically, the closing balance should be 20 for Company B, based on the company-level dimension.
To address this, I recommend creating two dimension tables—one for the calendar and another for the company—and establishing relationships between these dimensions and your opening balance and Net Cash Flow fact tables, as outlined below:
I would then create a cumulative measure for the closing balance using both the NetCashFlow and Opening Balance, as shown below:
Closing Balance =
VAR CurrentDate = MAX('Calendar'[Date])
RETURN
CALCULATE(
SUM(NetCashFlow[Value])+sum('Opening balance'[Value]),
FILTER(
ALL('Calendar'),
'Calendar'[Date] <= CurrentDate
)
)
The resulting output looks like below which differs from your expected output:
From an accounting perspective, the cumulative cash balance is calculated over time. However, your output appears to accumulate across the row index, which may not reflect standard accounting practices.
I have attached an example pbix file.
Best regards,
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
23 | |
15 | |
12 | |
9 | |
8 |
User | Count |
---|---|
41 | |
32 | |
29 | |
12 | |
12 |