Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Starting Position:
Goal:
Approach:
Problem:
NB: I already tried DATESBETWEEN but failed to keep the start date dynamic
Check
https://community.powerbi.com/t5/Desktop/Inventory-Calculation/td-p/138540
https://community.powerbi.com/t5/Desktop/Calculate-inventory-on-a-given-date/td-p/71699
I have already checked out these threads, but the issue I'm faced with is a bit different:
Based on an overview of the current balances (with specific date X) I need to reconstruct the past balances (daily) by creating a measure that's subtracting the sum of purchases and adding the sum of sales that happened between each day and the date X
If date if fixed by a slicer then
Inventory till date = Var _min_date_for_inventory = CALCULATE(maxx(all('Date'[Date Filer]),'Date'[Date Filer])) Var _Todays_date=CALCULATE(maxx(ALLSELECTED('Date'[Date Filer]),'Date'[Date Filer])) Var _inventory= CALCULATE(sum(Sales[Sales Amount]),all(Sales[Sales Date].[Date]),Sales[Sales Date]<=_min_date_for_inventory) Var Sale_till_tody =CALCULATE(sum(Sales[Sales Amount]),filter(sales,Sales[Sales Date]<=maxx(Sales,Sales[Sales Date].[Date]))) Var purchase_till_tody =CALCULATE(sum(Sales[Sales Amount]),filter(sales,Sales[Sales Date]<=maxx(Sales,Sales[Sales Date].[Date]))) return _inventory -Sale_till_tody+purchase_till_tody
_inventory is optional , can be removed
will it work if the end date is fixed but the start date is variable?
Because the goal is to have a bar chart with the days on the x-axis which are the respective start dates.
For example:
User | Count |
---|---|
139 | |
113 | |
103 | |
77 | |
63 |
User | Count |
---|---|
135 | |
126 | |
110 | |
70 | |
61 |