We have a file of order history for supplies. Within a storeroom I would like to find the minimum order time for each item within a selected time period. We run 2-bin Kanban so two orders on the same day would indicate a stockout.
Primary key is Storeroom_Item#_Unit of Measure e.g. ABC123_005678_Box
Data is (simplified):
Primary key Order Date Order Qty
First, I'm trying to think if there's a single measure I could write against the data to get the minimum interval between two dates without a helper column, but I haven't figured it out. It seemed more elegant...
More likely I would create a helper column in either PowerQuery or DAX to provide the interval between dates and then just do a MIN([Interval]) expression. I prefer to use PowerQuery but I think I'd have to do a self-merge, but the files are big and I don't want to slow down the already-lengthy daily refresh process. Off the top of my head a DAX calculated column would probably be something along the lines of
=EARLIER([Order Date]) - CALCULATE(MAX[Order Date], FILTER(Orders, EARLIER([Primary key] = [Primary key] && EARLIER([Order Date]) > [Order Date]))
plus some condition to apply a blank value if the record is the first order within the time period. (Would I have to copy the whole CALCULATE segment into a wraparound IF statement?)
That's why I'm hoping for something prettier!
Primary key is Storeroom_Item#_Unit of Measure e.g. ABC123_005678_Box
Data is (simplified):
Primary key Order Date Order Qty
First, I'm trying to think if there's a single measure I could write against the data to get the minimum interval between two dates without a helper column, but I haven't figured it out. It seemed more elegant...
More likely I would create a helper column in either PowerQuery or DAX to provide the interval between dates and then just do a MIN([Interval]) expression. I prefer to use PowerQuery but I think I'd have to do a self-merge, but the files are big and I don't want to slow down the already-lengthy daily refresh process. Off the top of my head a DAX calculated column would probably be something along the lines of
=EARLIER([Order Date]) - CALCULATE(MAX[Order Date], FILTER(Orders, EARLIER([Primary key] = [Primary key] && EARLIER([Order Date]) > [Order Date]))
plus some condition to apply a blank value if the record is the first order within the time period. (Would I have to copy the whole CALCULATE segment into a wraparound IF statement?)
That's why I'm hoping for something prettier!