Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Starting Position:
Goal:
Approach:
Problem:
NB: I already tried DATESBETWEEN but failed to keep the start date dynamic
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 |
|---|---|
| 50 | |
| 40 | |
| 32 | |
| 14 | |
| 13 |
| User | Count |
|---|---|
| 87 | |
| 73 | |
| 37 | |
| 28 | |
| 26 |