SSMS peek at your tables using SELECT keyboard shortcut


I often want to see a sample of the table I’m querying as i’m writing my queries or stored procedures. For instance if I want to know the name of a column or even get a sample from one of the cells. The old and slow way to do this is obviously to SELECT TOP 10 * FROM <your table name>, however when you’re in the middle of a large or complex join you don’t want to move to a new window to type that out. Basically, because every time you do that a fairy dies.

The way you should do it is by making use of SSMS’s inbuilt query shortcuts. You can find these in Tools > Options > Keyboard > Query Shortcuts

As you can see I’ve added ‘SELECT TOP 100 * FROM ‘ as my Ctrl + 3 shortcut. So now I can highlight the table I want to peek at and hit Ctrl + 3 and the results will be show in the results window without having to do any extra typing.

Please full enjoy radio button deselect


I believe there’s a small issue with the way radio buttons work in web where there is no way to deselect a selected radio button once it’s been checked. Which is a problem if you have a form with an optional question on it that gets answered by mistake. The only way to reverse the checked radio button is to reset the form or reload the page, which is a problem if you have alarge form to fill out.

You can use the below code to allow users to double click a radio button to deselect it.

function(ele) {;

    ele.addEventListener('dblclick', function(){

    //This is used to clear the selection. Otherwise we'd need to refresh the form
    //if the user doesn't want to pick an option before saving the case.
    //NB. Because the click method will fire each time as part of the MDC component
    //if you double-click on a blank field it will fire the click method twice.
    //Which you could argue is expected behaviour

        const currentRadio = document.getElementById(;

        const radio = new;

            radio.checked = false;            

}); web – chipset search


This may not be the greatest code in the world, but it works for my purpose. I’m building a web app that has chips all visible for use in an emergency call centre. I want to be able to tab into the chipset and then type in order to quickly go to the chip I want instead of tabbing all the way along.

I make use of an attribute of the chip set itself to store the currently searched value. You can add an attribute by using the attr jquery function

Here’s the code:

if($(".mdc-chip-set").find(':focus').length != 0 && event.keyCode > 59 && event.keyCode < 91)
    //Clear any active timers
    clearTimeout($.data(this, "timer"));

    var searchString = "";    

    //Check if we've already got a string that we're searching
    searchString += $(".mdc-chip-set").attr("searchString");

    //Add the current key to the search string
    $(".mdc-chip-set").attr("searchString", searchString += String.fromCharCode(event.which).toLowerCase());

    //Find the currently focussed chip set and go through each of its children to
    //see which one matches
    const items = $(".mdc-chip-set").find(':focus').parent().children();
      //See if the ID of the chip matches the search string
        return false;

    //Set the timer
    $(this).data("timer", setTimeout(function()
    }, 500));


I’m searching the ID of my chip for what the user is entering, my IDs are in the format –, e.g. er-animal-type-chip–Dog

So as the user types we look for IDs where the searchable section matches what has been typed so far (well in the last 500ms anyway). Then we focus on that chip. Notice that the each function is existed from as soon as a match is found. Web – Resetting Selected Chips


I couldn’t find this documented anywhere when I was looking and it could be a gap in my javascript knowledge (it’s a gap in my javascript knowledge), but I was struggling to figure out how to reset the selected chips in a web chipset.

Here’s the HTML for the chipset:

<label class="mdc-label">Main Problem(s)</label>
class="mdc-chip-set mdc-chip-set--filter" id="er-problem-chipset"> % for (var i = 0; i .length; i++) { %>
class="mdc-chip" id="er-chip-problem--">
class="mdc-chip__checkmark" > class="mdc-chip__checkmark-svg" viewBox="-2 -3 30 30"> class="mdc-chip__checkmark-path" fill="none" stroke="black" d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
class="mdc-chip__text">%= problemTypeData[i].Problem%>
</div> <%}%> </div>

You can see the if for the chipset is:id="er-problem-chipset">

So we can use the below in a reset method:  

  //Make sure to use vanilla JavaScript here and not JQuery in order to
  //get the chipset
  const chipSetEl = document.querySelector('#er-problem-chipset');
  const chipSet = new mdc.chips.MDCChipSet(chipSetEl);

  //Go through all of the selected chips and set them to not selected
  chipSet.selectedChipIds.forEach(element => {

    const currentChip = new mdc.chips.MDCChip(document.getElementById(element));
    currentChip.selected = false;

We can take this one step further by going through all of the chipsets and resetting them all:  

  //Make sure to use vanilla JavaScript here and not JQuery in order to
  //get the chipset
  const allChipSets = document.querySelectorAll('.mdc-chip-set');

  //Go through all of the chip sets and reset them all
  allChipSets.forEach(currentChipSet => {

  const chipSet = new mdc.chips.MDCChipSet(currentChipSet);

  //Go through all of the selected chips and set them to not selected
  chipSet.selectedChipIds.forEach(element => {

    const currentChip = new mdc.chips.MDCChip(document.getElementById(element));
    currentChip.selected = false;


INR number to words with ARRAYFORMULA in Google Sheets


Amit Agarwal has put together a great little script for Google Sheets that turns INR (Indian Rupees) amounts into words. Like you’d need to use if you were writing a cheque.

You can find the original code here: INR Amount to Words

However in its current state it won’t work if you want to use it in an ARRAYFORMULA. You only need to make a small change though and the below code will help with that.

We just need to check if an array is being sent in the input and then either process each of the rows in the array, or process the single incoming row if appropriate.

function INR(input)
    return INR_(input);

function INR_(input) {........


As you can see I’ve renamed the original function to INR_ so that we can add the new functionality without breaking the original functionality.

The same logic can then be used to turn any function into one that will work in an ARRAYFORMULA. Because if you’re still coping VLOOKUPS all the way to the bottom of your sheet you’re wasting your time!

Tableau + Google Sheets -Line chart with missing dates


Recently I was tasked to created a line chart that showed movement of animals in an animal sanctuary over time. This data came in the form of survey counts taken each day for each area of the sanctuary like this:

Area Date Count
Kennel 1 03/01/2019 100
Kennel 1 04/01/2019 102
Kennel 1 05/01/2019 101
Kennel 1 08/01/2019 120
Kennel 1 09/01/2019 121

You’ll notice that there’s a gap in the data between the 5th of January and the 8th of January. Not a big problem when we’re looking at one single area as Tableau will auto fill our missing dates:


It’s pretty obvious we’re missing a day’s worth of data, and that’s fine here. We’re rightfully continuing on our data set. But what happens when we’ve got one set of records with every date recorded and one without? We take a big hit on the days we’re missing data:


How can we solve this problem? There are a bunch of different scenarios:

  • Areas that have all days
  • Areas that have all days up to a certain point x days ago
  • Areas that are missing some dates up to the current day
  • Areas that are missing some dates and the last record is y days ago

As you can see our data set becomes rapidly complex. Not particularly difficult to solve with SQL Server and a Tally table, but what happens when we’re restricted to the use of a Google Sheet that’s driven from a Google Form?

First create a calendar table with all of the dates in our data set:


Then we need to deal with any islands. Each record in our data set can be sorted by Area Name and Date. This allows us to find the date of the record previous to this one, we do this by sorting our data by Area Name and Date descending:

=sort('Form responses 1'!C2:K,1,true,2,false)

Then we need to add an ARRAYFORMULA to figure out the previous date:


The needs to go in the first row and runs for each column and simply does:

If the Area Name for the current record matches the Area Name from the previous date’s row (this is why we sorted descending), we use the previous date, else we use the current row’s date. So we get output that looks like this:

Area Date Count Previous Date
Kennel 1 09/01/2019 121 08/01/2019
Kennel 1 08/01/2019 120 05/01/2019
Kennel 1 05/01/2019 101 04/01/2019
Kennel 1 04/01/2019 102 03/01/2019
Kennel 1 03/01/2019 100 03/01/2019
Kennel 2 09/01/2019 76 08/01/2019
Kennel 2 08/01/2019 79 07/01/2019
Kennel 2 07/01/2019 72 06/01/2019
Kennel 2 06/01/2019 74 05/01/2019
Kennel 2 05/01/2019 74 04/01/2019
Kennel 2 04/01/2019 76 03/01/2019
Kennel 2 03/01/2019 76 03/01/2019

Now we have a date range that can be used to join to our calendar table in Tableau. If we join to our calendar table where the calendar date (in which we have every single date) is after the previous date, and less than or equal to the date of the record like below:


We now get a result that looks like this:


As you can see the Calendar Date fills in the gaps.

Dealing with data that’s not up to date uses the exact same technique, we just need to reverse the dates. So the Previous Date is now the date of the record and the Date is TODAY()-1, i.e. yesterday. There are a couple of steps to get this done in Sheets:

1: Get the all of the records where the last record we have is before yesterday:

=query(query('Form responses 1'!C:D,"select C,max(D) where C <> '' group by C"),"where Col2 < date '"&TEXT(DATEVALUE(today()-1),"yyyy-mm-dd")&"'")

So here we’re making a sub QUERY to get the max date for each Area Name, and then another QUERY to get just the records where the date is before TODAY()-1, i.e. yesterday. This would be easy in SQL Server by using a HAVING clause. We then need to get the count value for each of these records:

={"Heading";ArrayFormula(iferror(vlookup(A2:A&B2:B, {'Form responses 1'!C2:C&'Form responses 1'!D2:D, 'Form responses 1'!C2:L}, 9, 0 ), 0))}

I understand it’s difficult without an example, so when I get a chance I’ll put one together and provide a link. If you need one in the meantime, leave a comment and I’ll put something together.

The result is a line chart that has the latest count for each day and can show what would have been the count on any particular day chosen.



Embedded Google Maps not working with Google App Engine


This one was actually pretty easy to solve, but was interesting anyway.

Developing locally I was OK using http requests for my script files as my local server has now issues with using either http or https for requests. However, App Engine has other ideas. In my scripts file I was including the below reference:

This worked no problem on my machine, but when I published to Google App Engine I saw the below:


Once I changed the script to use HTTPS:

I also needed to add my new site to the list of allowed referrers, by going to the Google Cloud Dashboard > APIs and Services > Selecting my project from the dropdown > clicking Maps Javascript API > Credentials > Editing the credential and adding in a record for my site.

Then I was presented with what I wanted to see: