Input
8/1/2021
10/1/2021
12…..
1234
9/15/2021
9/15/2021
..3….
1234
6/1/2021
7/1/2021
12345..
1234
1/11/2021
1/22/2021
…4…
5678
3/15/2021
3/26/2021
1234567
5678
4/1/2021
4/1/2021
…4…
5678
4/5/2021
4/23/2021
12345..
5678
iVBORw0KGgoAAAANSUhEUgAAAXoAAAA0CAIAAAAL52RvAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAScQAAEnEB89x6jgAAABJ0RVh0U29mdHdhcmUAR3JlZW5zaG90XlUIBQAADRxJREFUeF7tnd+OFccRh/0GzhvEb4DfwH4D+w3sN0jewFxxhxIpcGEJCS4s+WKJsYR9w14kYq8WIWE2CgqKMVqL4FUQ8kIisCVL5NtTvZXa6j/TZ2fm7J51fWqNTtdU93QPU7+pnjNneetNEATBSgi5CYJgRYTcBEGwIk5Gbv7y5D83Hu2nSrAOPHny5O7du7u7u6keBMuzarl5/OLn97/49q0/fUNJpmAdCLkJxrNSubn37NVvPv2baM2ycvPjT7+c395DqhCsZApWSMhNMJ6Vys0n2z+o1iwlN1anWIgla7BCQm6C8ayH3Lz96Y62Crk5EUJugvGsh9zYViE3J0LITTCekJugi5CbYDwhN0EXITfBeEJugi5CboLxhNwEXYTcBOMZkJsff/rlj988+3jz+/e/+Na+MkN59/OH2Nl779mr5D3EycoN4zy/vff72/9iLmz5/OWjF2lfMETITTCeAbn54KvvbKjXyjvXHhDAgy/gLSU3f7j3b3SBgq7ZVmgcSmHLoABdffDcaaUW7PSAqibXEuz965P/Skmmxe8wRLlEvJJ1AbvUv92zok2sdvNZ+0mmCnaEM70GGXITjGdAbj7a3HXx2SiEbmpWYSm5sZ7t8t6f/5naZBCHTq2KBZ+GLljNRQTxRGLUIiW5LrB2TmCy1kEN1f+31/6erEffNvrd7SfJmuHm2HPEYxByE4xnQG6463LRE8+EHGJhCxYbD1LaiQatrHOyVrCe7dKQm3Of/yN3luLsRGxqk2GdmXWeKLkBWHkalGCwg+QUJesiv1M7pXZuUSL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JFXITjKclNwLXPRKgmQ4xT9hwC7U3Zz4TP+rD1U+QNy56/OmBbulKOqQQUbUbuFBsxYEGv6tiJAyvoVaMvDFgBiZt2Q6ugBowcj3i4JiZqUxQ5pisFThv6kxpn8bjEXITjGdYbs4SxCFxjnxIIaRZ3M2RC+RwFNUaZCtZ14eQm2A8vy65OUHsmm4wWzmFhNwE4wm5WQUsA+13TKvJp6Yl5CYYT8jNKmDhplrz3oiHzSdIyE0wnpCb2bn37JVNbdovXp9aQm6C8YTczAhrqPPbe1Zr1jS1gZCbYDwhNxODoCAr7x79i/FS3q7/x3Wnn5CbYDwhNxPjJEYLWjPH6zArI+QmGE/IzcQ4lZHy0ebu+uY1QshNMJ6Qm4nR957ZfrL9w9UHz9fxa++cly9fPn36NP/zUUHQT8hNEAQrIuQmCIIVEXITBMFKePPmf4GyDTAL6GK4AAAAAElFTkSuQmCC
Weekly Challenge #310
This week we have a data restructuring challenge regarding equipment maintenance schedules. Imagine that you’ve been tasked with creating an Excel spreadsheet which reports the days on which a truck was in the shop for service. Currently the data are structured such that there are multiple records per truck ID, a date-in value and a date-out value, and a “pattern” variable to indicate on which days the truck was actually being serviced.
A large shipping firm has a fleet of thousands of trucks (though the data for this challenge is provided for only two trucks). The company’s management needs the maintenance history for every truck, placing a 0 or a 1 in the column for every date - beginning at the earliest date in the data and continuing to the latest date – on which the truck was being serviced.
The In-Date and the Out-Date variables indicate the start and end date of the period of time within which the truck was taken off line for service, but not necessarily serviced on each and every day within that span of time. The “Pattern” value indicates which days within the indicated time span that the truck actually received service.
The “Pattern” variable is a string variable in the form of “123.567” or “…456.” or “……7” or any such variation, where the number corresponds to the weekday (with a “1” indicating “Monday” and a “2” indicating a “Tuesday” etc.) and the periods within the pattern indicating a day when the truck was not being serviced. So, for example, if a pattern value is “12.4567” then we know it was in the garage for every day of the week, except for Wednesday. More, a value of “12345..” indicates that the truck had the weekend off.
Hint: This challenge can be solved with and without the use of a macro
C:\Users\A140171\AppData\Local\Temp\Engine_31788_b12e969564aa40ccbaeb69d1dadae492_\Engine_6436_854e5daba1a04e619145eb750509914a_.yxdb
Single
Profile
Output
Output.yxdb
Output.yxdb
C:\Users\A140171\AppData\Local\Temp\Engine_31788_b12e969564aa40ccbaeb69d1dadae492_\Engine_6436_3e4cedfcf19143fa8369c8dff4670abf_.yxdb
Single
Profile
In-Date
English
MM/dd/yyyy
DateTime_Out
Convert datetime format to be able to do days diff
Convert In-Date From:
MM/dd/yyyy
Out_Date
English
MM/dd/yyyy
DateTime_Out
Convert datetime format to be able to do days diff
Convert Out_Date From:
MM/dd/yyyy
Rename Date out columns
Rename Date out columns
Days difference for row generation later
Days_Count
Int32
4
0
[Days_Count] <= [Days]
Days_Count + 1
Generate rows based on the days between the 'In' and 'Out' dates
Generate rows based on the days between the 'In' and 'Out' dates
Create a date column with 1 day increment on date in
In_Date_Cont
English
day
Day_Name
Find day name from the new date in coumn
Convert In_Date_Cont To:
Custom
Friday
5
Monday
1
Saturday
6
Sunday
7
Thursday
4
Tuesday
2
Wednesday
3
Days numeric value
Days numeric value
Bring in days numeric value
Bring in days numeric value
Flag with 0 or 1 for service days
Pattern
Replace
Pattern
Warn
Pattern_Matched
Clean Pattern column to remove non-number values
Clean Pattern column to remove non-number values
Find the min and max of dates to be able to show full period of service days for both trucks
Find the min and max of dates to be able to show full period of service days for both trucks
Days difference for row generation later
Days_Count
Int32
4
0
[Days_Count] <= [Days]
Days_Count + 1
Generate rows based on the days between the 'In' and 'Out' dates
Generate rows based on the days between the 'In' and 'Out' dates
Create a date column with 1 day increment on date in
Bring in the two datasets together, with join on dates
Bring in the two datasets together, with join on dates
Warning
All
ByName
,
crosstab dates to column
crosstab dates to column
In_Date_Cont
English
yyyy-MM-dd
DateTime_Out
datetime format converswion
Convert In_Date_Cont To:
yyyy-MM-dd
Formula
replace([_CurrentField_],'_','-')
Change the heading to match the desired output
Change the heading to match the desired output
Simple
IsNotNull
Truck ID
True
fixed
2022-03-15 16:19:55
0
2022-03-15 16:19:55
2022-03-15 16:19:55
!IsNull([Truck ID])
All
if isnull([_CurrentField_]) then 0 elseif isempty([_CurrentField_]) then 0 else [_CurrentField_] endif
replace nulls/blanks with 0s
if isnull([_CurrentField_]) then 0 elseif isempty([_CurrentFi...
make unique dates for both trucks, take max flag where there are overlaps
make unique dates for both trucks, take max flag where there are overlaps
C:\Users\A140171\AppData\Local\Temp\Engine_31788_b12e969564aa40ccbaeb69d1dadae492_\Engine_6436_43b45921e2ce4d069b1177f32fa1a3bd_.yxdb
Single
Profile
Alteryx Educational Asset - Terms and Conditions
Use of this Alteryx asset is for educational purposes only and bound by the conditions set forth on alteryx.com/terms-and-conditions. Alteryx Information may not be reproduced, transmitted or distributed without Alteryx, Inc.'s permission.”
Horizontal
Weekly Challenge John Norton 310_Start File_Solution by OJ