I have developed a TimeSheet in Excel which lets management see time written by lawyers. When lawyers write and submit their time, a csv timesheet file is saved to the Server in a "TimeSheet-Processing" folder (meaning timesheets that are not yet imported into the separate accounting system). As timesheets are imported into the accounting system, they are moved to a "TimeSheets-PROCESSED" folder so they are not processed to the accounting system.
My Reporting module allows management to see a TimeSheet report combining timesheets from both the "TimeSheet-Processing" folder and the "TimeSheets-PROCESSED" folder. To do this I have a series of queries (all Connections only until the last query in the series) that transform the timesheets in both of these folderes and then joins (appends) them.
Qry 1: import timesheets in the "TimeSheet-Processing" folder and transform
Qry 2: import timesheets in the "TimeSheets-PROCESSED" folder and transform
Qry 3: join (append) Queries 1 and 2 above.
(There are 2 more queries in the series after that but the errors occur in the above).
This has been working blissfully fine until...(drumroll)...the "TimeSheet-Processing" folder is cleared after importing into the accounting sytem. The "TimeSheet-Processing" folder is now empty: no files. No error occurs until this step in the query...
#"Changed Type1" = Table.TransformColumnTypes(#"Filtered Rows1",{{"Duration", Int64.Type}}),
...Expression.Error: The column 'Duration' of the table wasn't found...because there is no "Duration" column to be found given there are no files.
And of course, Qry 3 fails being dependent on Query 1.
Is there some way to deal with queries lacking the source files when run?
POSSIBLE WORKAROUND: given that my client firm already has submitted timesheets, the "TimeSheets-PROCESSED" folder will always be populated. I could adjust Queries 1 & 2 to just import but not transform. Then append in Query 3 and transform.
ISSUES with the above workaround: I plan on rolling out the solution to future clients who will initially have no timewrite data. You would think there would be a way for the queries to just return an empty set when the source files for the query are absent.
As an aside, the queries are refreshed programmatically and an error occurs when the above queries fail.
Thanks and regards,
Greg
Update: I tried the POSSIBLE WORKAROUND and it worked as at least one of the folders contained timesheets.
Still, I'm curious if there's a way to deal with the worst case scenario: no files in either folder.
Hi Greg,
The only other workaround I could think of is to put an empty template/dummy workbook in that folder. This workbook contains the headers but no data and it is kept permanently in the folder.
Mynda
Thanks, Mynda. (Quick turnaround!) Yes, I was thinking of that too but struggling with the concept of management seeing the dummy data. I didn't think of just putting the headers only.
Thanks, again and great course!
Kind regards,
Greg
Glad I could help, Greg.