Forum Discussion
Wonter
2 years agoFrequent Visitor
Inventory Level for every day, also dates with no row entry
Hi all, I have a question about the inventory levels. I've tried so many different options, but nothing worked yet. I'm looking for a way to visualise every day in a table with for every day the ...
- 2 years ago
Try this measure. It requires a date table with a 1:* relationship with the fact table HistoricalInventory. In the visual, use Dates[Date].
Minimum Stock = VAR vCurrentDate = MIN ( Dates[Date] ) VAR vPreviousDate = CALCULATE ( MAX ( HistoricalInventory[history_date] ), Dates[Date] < vCurrentDate ) VAR vFilterPreviousDate = TREATAS ( { vPreviousDate }, Dates[Date] ) VAR vStockPreviousDate = CALCULATE ( MAX ( HistoricalInventory[stock] ), vFilterPreviousDate ) VAR vResult = IF ( // if Dates[Date] does not exist in HistoricalInventory, use the last value ISEMPTY ( HistoricalInventory ), vStockPreviousDate, MAX ( HistoricalInventory[stock] ) ) RETURN vResult - 2 years ago
Thanks for the link. I found the issue. The variable vPreviousDate in the measure needs to use date, not historical_date (the relationship with DateTable is based on date, not historical_date.
VAR vPreviousDate = CALCULATE ( MAX ( kiosks_historicalkioskarticle[date] ), DateTable[Date] < vCurrentDate )
DataInsights
Super User
2 years ago
Thanks for the link. I found the issue. The variable vPreviousDate in the measure needs to use date, not historical_date (the relationship with DateTable is based on date, not historical_date.
VAR vPreviousDate =
CALCULATE (
MAX ( kiosks_historicalkioskarticle[date] ),
DateTable[Date] < vCurrentDate
)
Wonter
2 years agoFrequent Visitor
DataInsights This works indeed, thank you very much! I really appreciate it.