I am pretty new to PowerBI and I am trying to calculate a rolling "Monthly On-Time Delivery" calculated column.
ADDED DAILY SHIPMENT COUNT (Disregard the incorrect MTD Shipment Count title)
Each row represents a single day in the Matrix
For each day I want to get the MonthShippedTotal / (MonthShippedTotal-MonthPastDue), this should give me my rolling on time delivery percentage.
This is what I have so far but the results are way off:
> MonthlyOTD = VAR RowDate = opr_shipments[SHIP_DATE] RETURN
> CALCULATE (
> DIVIDE((COUNT(opr_shipments[CREATE_TIMESTAMP])-COUNTAX(opr_shipments,opr_shipments[PAST_DUE]="1")),COUNT(opr_shipments[CREATE_TIMESTAMP]),0),
> FILTER (
> opr_shipments,
> opr_shipments[SHIP_DATE] <= RowDate
> && MONTH ( opr_shipments[SHIP_DATE] ) = MONTH ( RowDate ) && YEAR ( opr_shipments[SHIP_DATE] ) = YEAR ( RowDate )
> )
> )
MTD Shipments Calc:
MTD Shipments =
VAR RowDate = opr_shipments[SHIP_DATE]
RETURN
CALCULATE (
SUM ( opr_shipments[Daily Shipments] ),
FILTER (
opr_shipments,
opr_shipments[SHIP_DATE] <= RowDate
&& MONTH ( opr_shipments[SHIP_DATE] ) = MONTH ( RowDate ) && YEAR ( opr_shipments[SHIP_DATE] ) = YEAR ( RowDate )
)
)
Past Due Total Calc:
PastDueTotal =
VAR RowDate = opr_shipments[SHIP_DATE]
RETURN
CALCULATE (
SUM(opr_shipments[Daily Shipments]),
FILTER (
opr_shipments,
opr_shipments[SHIP_DATE] <= RowDate
&& DAY ( opr_shipments[SHIP_DATE] ) = DAY ( RowDate ) && opr_shipments[PAST_DUE] = "1"
)
)
For each month this calc would start over.
My desired output is: Jan 1 | 98% Jan 2 | 98.3% Jan 3 | 95% ... Jan 31 | 94.5% Feb 1 | 100%