Forum Discussion
Hossam_Khattab
4 months agoRegular Visitor
Days Forward Coverage (DFC) Measure
The dashboard here shows a projected inventory ( a dynamic projected inventory which is calculated for every day based on the elements above it) Dynamic Projected Inventory = Dynamic Selected ...
- 4 months ago
Hi Hossam_Khattab,
Try below DAX
DFC (Days Supply) =VAR CurrentDate =MAX('Date'[Date])
VAR InventoryAvailable =[Dynamic Projected Inventory]
VAR FutureDays =FILTER(ALL('Date'[Date]),'Date'[Date] > CurrentDate)
VAR DemandTable =ADDCOLUMNS(FutureDays,"DailyDemand", CALCULATE([Dynamic Selected Demand]),"CumDemand",VAR d = 'Date'[Date]RETURNCALCULATE([Dynamic Selected Demand],FILTER(ALL('Date'[Date]),'Date'[Date] > CurrentDate &&'Date'[Date] <= d)))
VAR FirstExceededDay =MINX(FILTER(DemandTable, [CumDemand] > InventoryAvailable),'Date'[Date])
VAR FullDaysCovered =COUNTROWS(FILTER(DemandTable,[CumDemand] <= InventoryAvailable))
VAR PrevCumDemand =MAXX(FILTER(DemandTable,'Date'[Date] < FirstExceededDay),[CumDemand])
VAR RemainingInventory =InventoryAvailable - COALESCE(PrevCumDemand,0)
VAR ExceededDayDemand =MAXX(FILTER(DemandTable,'Date'[Date] = FirstExceededDay),[DailyDemand])
VAR FractionalDay =DIVIDE(RemainingInventory, ExceededDayDemand, 0)
RETURNIF(ISBLANK(FirstExceededDay),FullDaysCovered,FullDaysCovered + FractionalDay)🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together! - 3 months ago
Find the Correct logic working code below,
DFC =VAR CurrentDate = MAX('Date'[Date])VAR CurrentInventory = [Dynamic Projected Inventory]RETURNIF(ISBLANK(CurrentInventory),BLANK(), -- If Inventory is blank, return BLANK and stop here-- Otherwise, proceed with the full calculationVAR FutureDemandTable =FILTER(ALLSELECTED('Date'),'Date'[Date] > CurrentDate)VAR CumulativeDemandTable =GENERATE(FutureDemandTable,VAR RowDate = 'Date'[Date]RETURNROW("RunningTotalDemand",SUMX(FILTER(FutureDemandTable, 'Date'[Date] <= RowDate),[Dynamic Selected Demand]),"DailyDemand", [Dynamic Selected Demand]))VAR FullDays = COUNTROWS(FILTER(CumulativeDemandTable, [RunningTotalDemand] <= CurrentInventory))VAR MaxFullDemand = MAXX(FILTER(CumulativeDemandTable, [RunningTotalDemand] <= CurrentInventory), [RunningTotalDemand])VAR RemainingInventory = CurrentInventory - IF(ISBLANK(MaxFullDemand), 0, MaxFullDemand)VAR NextDayDemand =MINX(FILTER(CumulativeDemandTable, [RunningTotalDemand] > CurrentInventory),[DailyDemand])VAR FractionalDay = DIVIDE(RemainingInventory, NextDayDemand, 0)RETURNIF(CurrentInventory <= 0, 0, (IF(ISBLANK(FullDays), 0, FullDays) + FractionalDay)))
grazitti_sapna
4 months agoSuper User
Hi Hossam_Khattab,
Try below DAX
DFC (Days Supply) =
VAR CurrentDate =
MAX('Date'[Date])
VAR InventoryAvailable =
[Dynamic Projected Inventory]
VAR FutureDays =
FILTER(
ALL('Date'[Date]),
'Date'[Date] > CurrentDate
)
VAR DemandTable =
ADDCOLUMNS(
FutureDays,
"DailyDemand", CALCULATE([Dynamic Selected Demand]),
"CumDemand",
VAR d = 'Date'[Date]
RETURN
CALCULATE(
[Dynamic Selected Demand],
FILTER(
ALL('Date'[Date]),
'Date'[Date] > CurrentDate &&
'Date'[Date] <= d
)
)
)
VAR FirstExceededDay =
MINX(
FILTER(DemandTable, [CumDemand] > InventoryAvailable),
'Date'[Date]
)
VAR FullDaysCovered =
COUNTROWS(
FILTER(
DemandTable,
[CumDemand] <= InventoryAvailable
)
)
VAR PrevCumDemand =
MAXX(
FILTER(
DemandTable,
'Date'[Date] < FirstExceededDay
),
[CumDemand]
)
VAR RemainingInventory =
InventoryAvailable - COALESCE(PrevCumDemand,0)
VAR ExceededDayDemand =
MAXX(
FILTER(
DemandTable,
'Date'[Date] = FirstExceededDay
),
[DailyDemand]
)
VAR FractionalDay =
DIVIDE(RemainingInventory, ExceededDayDemand, 0)
RETURN
IF(
ISBLANK(FirstExceededDay),
FullDaysCovered,
FullDaysCovered + FractionalDay
)
🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!