Forum Discussion
Filtering and splitting a value based on date range
Hi kleighton ,
I calculate the ordernumber corresponding to the periods when jobs have changed over to two job numbers. The formula for the created calculated column is as follows:
ordernumber =
var MinDate =
MINX(
FILTER(
'Work',
'Work'[machineid] = Runtime[Column1.machineId]
&& 'Work'[Column1.EndDate] > Runtime[Column1.endTime]
),
'Work'[Column1.EndDate]
)
var MaxDate =
MAXX(
FILTER(
'Work',
'Work'[machineid] = Runtime[Column1.machineId]
&& 'Work'[Column1.EndDate] < Runtime[Column1.endTime]
),
'Work'[Column1.EndDate]
)
var OrderNum =
CALCULATE(
VALUES('Work'[Column1.OrderNumber]),
FILTER(
ALL('Work'),
'Work'[machineid] = Runtime[Column1.machineId]
&& 'Work'[Column1.StartDate] <= Runtime[Column1.startTime]
&& 'Work'[Column1.EndDate] >= Runtime[Column1.endTime]
)
)
var MaxOrder =
CALCULATE(
VALUES('Work'[Column1.OrderNumber]),
FILTER('Work','Work'[machineid] = Runtime[Column1.machineId] && 'Work'[Column1.EndDate] = MinDate)
)
var MinOrder =
CALCULATE(
VALUES('Work'[Column1.OrderNumber]),
FILTER('Work','Work'[machineid] = Runtime[Column1.machineId] && 'Work'[Column1.EndDate] = MaxDate)
)
return
IF( ISBLANK(OrderNum), CONCATENATE(MinOrder,MaxOrder), OrderNum )
Is this what you want?
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- kleighton5 years agoHelper II
Hi Winniz,
Apologies for the late reply. Thanks for this, it is working as you described, but does not resolve what i need.
So as you seen from the sample file, i want to report on the Duration per Ordernumber the machine has been in different states (Running, error etc).
whilst your solution has now brought the associated Order numbers before and after the work changeover (Thanks again), it still doesnt help me get the specific duration for each of them.
I suppose this calculation may need to be stored in a new table as it will create additional rows of data by splitting the duration into its relevant Ordernumbers?..
Thanks in advance,
Keith