I have a technical problem that I cannot solve...
In my model I have two tables. one for Orders and one for Production records.
The table of orders contains, among other data, also the required quantity and the estimated date for shipment.
The table of production contains the production events in related to the different orders - quantities and their date.
For example I have order X for 6,000 units to be delivered at Aug 1, 2018 and at the Production table I can find the following related records for production:
For each order I would like to get the date that all required quantity of the order as been manufactured.
This shall be the earliest date that the fulfill the condition that all required units were produced.
(earliest date since we might produce an extra units).
At the example mentioned above the expected date shall be Aug 2
Any idea how it can be done ? by DAX or Power Query ? can it be a calculated column?
Thanks in advance.
assuming following tables structure
this code will work as calculated column in Order
ProducedDate = VAR RequestedQuantity = 'Order'[Quantity] VAR AccumulatedProduction = ADDCOLUMNS ( Production, "ProducedQuantity", CALCULATE ( SUM ( Production[Quantity] ), FILTER ( Production, Production[Order] = EARLIER ( Production[Order] ) && Production[ProductionDate] <= EARLIER ( Production[ProductionDate] ) ) ) ) VAR CompletedProduction = FILTER ( AccumulatedProduction, [ProducedQuantity] >= RequestedQuantity ) RETURN CALCULATE ( FIRSTDATE ( Production[ProductionDate] ), CompletedProduction )
EDIT - I assume there is join between the tables on Order
Thank you very much on your prompt reply.
Unfortunately this yield to me error of "there is not enough memory to complete the operation" so I cannot use this solution...
I think I need to provide some more info:
1. the table of production has many many records (it is large table...)
2. the relation between orders to production is one to many (many production records related to a single order)
3. I already have the following 2 measures:
Cumulative Production = CALCULATE ( [Total Production] ,FILTER (ALLSELECTED( Production ),Production[Date] <= MAX ( Production[Date] )) )
Order Cumulative Production = CALCULATE([Cumulative Production], FILTER(Production,Production[Date] <= LASTDATE(Orders[RequiredDate])))
Any other solution ?
Thanks in advance