In my work, I recently had an issue with absence data where the system had generated some duplicate data. Short of creating an actual report within the system (which I neither have the time or access to do), I decided to have a go at creating a reusable template that I could easily share with anyone. The idea was to take the data and produce a number of specific outputs, including the duplicates and a specific set of ‘All Day’ duplicates.
I started the template by creating a spreadsheet with three tabs: Sheet2, DUPLICATES and ALLDAYDUPLICATES. Sheet2 contained a summary of the ID, event data, name, absence type and event type.
=QUERY(Sheet1!A1:R,"SELECT A,R,E,F,G WHERE A IS NOT NULL")
I then made a column of unique data by combining the ID and event date. To do this, I used Ben Collins’ trick using formulas in a named range as a means of capturing the variability of the data.
=ARRAYFORMULA(CONCAT(INDIRECT(IDS),INDIRECT(DATES)))
With IDS named range being:
="'Sheet2'!A2:A"&COUNT(Sheet2!A2:A)+1
and DATES named range being:
="'Sheet2'!B2:B"&COUNT(Sheet2!B2:B)+1
I then used the column of unique data to create a TRUE / FALSE column as to whether the absence might be a duplicate.
=ARRAYFORMULA(countif($F:$F,(INDIRECT(UNICON)))>1)
With the UNICON named range being:
="'Sheet2'!F2:F"&COUNTA(Sheet2!F2:F)+1
I borrowed this formula in part from Collins who used something similar to use Conditional Formatting to highlight duplicates:
=countif(A:A,A1)>1
In the DUPLICATES tab, I created a QUERY that brought in the duplicates ordered by date
=QUERY(Sheet2!A:G, "SELECT A,B,C,D,E WHERE G = TRUE and A IS NOT NULL ORDER BY B")
While in the ALLDAYDUPLICATES I created another QUERY which focused on ‘All Day Absences’
=QUERY(DUPLICATES!A:E, "SELECT A,B,C,D,E WHERE E = 'AllDayAbsence'")
With all this in place, to query any data, I make a copy of the template. I then import the absence data exported from the external system. Although I could possibly copy and paste the data, I have found that this is fraught with dangers. In regards to the ‘Import Location’ I select Insert New Sheet(s). This then loads the new data into Sheet1. I then click on the formula in Sheet2!A1 and press enter to refresh the QUERY formula and populate the rest of the spreadsheet.
For those interested, a copy of the spreadsheet can be found here.
—
Growing up, I never really went deep into the world Microsoft Excel. It was not until exploring Google Sheets that I started appreciating the power and potentials. One of the consequences of this is that a lot of the habits that I have learnt are not applicable in reverse. For example, Ben Collins has a site discussing the power of moving from Excel to Google Sheets. This includes a discussion of IMPORT features and the QUERY function. However, there is nothing that I am aware of that goes the other way. I guess this is the nature of coding in general. Every language has its own set of affordances and we work within these constraints. What the situation has taught me though is that sometimes solving problems is about working with what is at hand. I guess the challenge is developing our box of tricks so that we do have something at hand. In some ways, this reminds me of something Amy Burvall once said:
“in order to connect dots, one must first have the dots”
So what about you? What small tools have you created to solve a particular problem? What are the strategies that you use to continually add to your toolbox so that you are always ready when a problem may arise? As always, comments and webmentions welcome.
If you enjoy what you read here, feel free to sign up for my monthly newsletter to catch up on all things learning, edtech and storytelling.
Using Google Sheets to Make Small Tools to Solve Specific Problems by Aaron Davis is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Mentions
Likes