Forum Discussion
Problems with opening and closing balance
So, my issue is rather simple. I have a list of products, let's say
- Product 1
- Product 2
- Product 3
And I have a list of transactions from 2015 up to 2017, around this products, so it looks like this
Date | Product | Quantity | Comment
------------------------------------------------------
2015-01-01 | Product 1 | 5 | Sales
2016-02-01 | Product 1 | -2 | Acuisition
....
...
What I want in the end is a pivot table, containing my products, with 3 columns: 'opening balance', 'period's change', 'ending balance', with a slicer on a date (month, year, day, anything), which will allow me to see the balance of each product for every day, every month of every year.
What I have tried:
- Using TOTALYTD , it works perfect, but just gives me balance for only the selected year. I need all of them
- Combining last method, also creating a parameter in power query, to pre-agregate previous year data, and store them as "previous year closing balance", yet parameters are not convinient to control
- Using cumulative sum with something like this
Starting Ballance:=CALCULATE(SUM([Qty]),all(Transactions[Date]),DATESBETWEEN('Calendar'[Date], min('Calendar'[Date]), min(Transactions[Date])-1))Basically I sum up all the transactions that happened before the filtered date, simple. This works perfect except the cases, where there were no transactions with a particular item in the selected period, so I get a blank value inside the formula and an error occours.
Also tried this solution, had the very same result.
I know that there is a nice thing called "time intelligence" in power bi system, but all it has for the moment limits me inside one year, there are no "lifetime" functions.
Looks like I need something like "last non blank" but I can't figure out how to implement it here.
It'd be veeeery nice if anyone could help me in this, I have a feeling that I'm just missing something rater simple.
- Anonymous9 years ago
I was using community provided solution wrong. Now it works perfect. Had to put date table date field in formula instead of transactions table date field.
1 Reply
- AnonymousNot applicable
I was using community provided solution wrong. Now it works perfect. Had to put date table date field in formula instead of transactions table date field.