cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
junaidch278
New Member

Opening balance from running total column

Hi there.

Thanks in advance. I am having a problem while calculating opening and closing balance on the PBI from the following table.

junaidch278_0-1686319876371.png

I have tried these 2 dax calculations but it is not reflecting the desired results.
CALCULATE
(
min(FactStockMovement[ClosingBalance]),
FILTER(
ALLSELECTED(DimDate[Date]),(DimDate[date])=min(DimDate[date])
))
CALCULATE(
min(FactStockMovement[ClosingBalance]),
FILTER(
ALLSELECTED(DimDate[Date]),(DimDate[date])=FIRSTDATE(DimDate[date])
))
Can anyone guide me how can i calculate opening and closing balance from the table.
the 1st expression is working for the values having opening and closing balance, but if there is no transaction on the min and max date we are getting null.
looking forward to hearing from you guys.
3 REPLIES 3
some_bih
Memorable Member
Memorable Member

Hi @junaidch278 to provide clear solution in some way, the amounts as input and output should be clear.

In general, are these inputs for amount like stock, etc cash balance or like income, etc salary.

What about wanted output?  From picture stock is wanted to be shown, like opening balance +/- inputs / outputs = ending balance, right?

Give us some example data as input and expected output per X (x could be date, product key...)

Sarajevo, Bosnia and Herzegovina
junaidch278
New Member

HI @some_bih 
I have the requirement where user can select any date. it can be a single day or a week or a couple of months. and the solution you perposed is workable for month, quarter and year opening and closing balance.
i'm looking for a way to select dynamic minmum date so i can utilize the running totals to get the correct results.
please reach out to me if you need aditional clarity.

some_bih
Memorable Member
Memorable Member

Hi @junaidch278 you should probably use functions OPENING/CLOSINGBALANCE* for DAX. check link

https://www.sqlbi.com/tv/closingbalancemonth-closingbalancequarter-closingbalanceyear-dax-guide/ 

Sarajevo, Bosnia and Herzegovina

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors
Top Kudoed Authors