Interactive spreadsheets 2: checkboxes
Right, so in part one of this series we covered buttons, so not it’s time to tackle the next interactive element: checkboxes!
I think it’s safe to assume that we’ve all used a checkbox before, digitally or physically (on paper that is). But, when you use dashdash in combination with checkboxes you can achieve some very powerful results in your spreadsheets - something you probably have already experienced pretty much any time you’ve used one of our spreadsheet templates.
In this tutorial, we’re going to cover:
- adding checkboxes
- checkbox logic
- how checkboxes, formulas, and buttons can interact
- creating an interactive spreadsheet with buttons, checkboxes, and formulas.
Let’s get started !
To add a checkbox to a cell:
- Select the cell where you want the button to appear.
- In the editor bar, go to More action elements and select Checkbox .
Alternatively, you can also use our Quick Commands:
- Select the cell where you want the button to appear.
- Press CMD + K (or Ctrl + K ), type in Checkbox , and press Enter .
A checkbox can have two “states”:
So, just like with buttons, you can use checkboxes in conditional functions to trigger some kind of action.
In the example below, we want to display True! Checkbox checked whenever the checkbox is checked, and False. Checkbox not checked whenever it’s not. All we need to do is use a simple
=If(B2=TRUE,"True! Checkbox checked","False. Checkbox not checked")
Now that we’ve covered the basic logic of checkboxes, let’s have a look at how to combine them with a few different functions .
Combining checkboxes with functions
A simple implementation of using functions with checkboxes is to count how many are checked. All we need to do is count how many of the cells are
And of course, we combine our checkboxes with buttons and some Boolean function. For example, let’s say we only want to trigger the contents of a cell only after two checkboxes and a button is clicked. We just need to use an
AND() function to say: “If the button is clicked and checkbox one is checked and checkbox two is checked, then do this, otherwise, don’t do anything”.
The formula in cell F2 in the example above is:
=IF(AND(C2=TRUE,D2=TRUE,E2="Yes, log it already!"),INSERT(A1:B1,A2:B2,A6:B6),"Not logging anything")
If you’ve ever used the Send SMS with Infobip template, or pretty much any other dashdash template, you’ll know that using checkboxes with buttons or formulas are a winning combination - you can introduce some very complicated logic into your spreadsheets.
Right - and now that you’ve digested all of that, let’s create an interactive spreadsheet with checkboxes!
Interactive spreadsheet example
So in this example, we’ll make use of the same Crunchbase function that we used in part one of this series. But, we’re going to add some more logic into the mix just to make things a bit more interesting.
Set up a new view with the following content:
|A1||Last Funding Date|
|B1||Last Funding Type|
|G2||Get Data button|
|F6||Auto Log Top 10|
It should look a little like this:
Now, the logic we want to use in this example is as follows:
If someone clicks the button, we’ll use the
SEARCH_COMPANIES_BY_FUNDING_CRUNCHBASE() to get all the companies matching the criteria. However, if someone checks the Schedule Function checkbox, then it’ll execute the function automatically every hour - the user won’t be able to manually execute the function (and a message will appear explaining why)
If the user wants, they can automatically log the top 10 results each time the function is executed.
You’ll need to create a Log view for this part.
To get the logic for part one:
In cell H2, paste in the following formula:
=IF(AND(G2="Get Data",NOT(G4=TRUE)),OVERWRITE_DATA(PARSE(SEARCH_COMPANIES_BY_FUNDING_CRUNCHBASE(A2,B2,C2,D2,E2,F2),"organizations"),A9:9),IF(G4=NOT(TRUE),"","You have scheduled the search."))
Now in cell H4, this one:
=IF(G4=TRUE,SCHEDULE(OVERWRITE_DATA(PARSE(SEARCH_COMPANIES_BY_FUNDING_CRUNCHBASE(A2,B2,C2,D2,E2,F2),"organizations"),A9:9),"every hour"),"Function not scheduled")
And now the logic for part two:
In cell H6, paste in the following formula:
=IF(G6=TRUE,INSERT(A9:G9,A10:G20,'Log'!A1:G1),"Not logging information")
Great, now if you’ve entered all that correctly when you enter some search parameters and press the Get Data button, you’ll get a whole list of companies. And then if you check the Schedule Function checkbox and try to click the Get data button - we should see that it won’t let us.
Lastly, if we check the Auto Log Top 10 checkbox, we should see that our data is automatically inserted into our Log view.
Pretty cool right!? But of course, there’s plenty more to do (as you may have seen in the last animation - there’s a couple of extra checkboxes), so as always, we have some challenges for you.
Challenge: automatic emails and log clearing
Today’s challenge is pretty tricky as it uses three functions we haven’t covered in depth yet:
RANGE2JSON(). But don’t worry, we’ll include a helpful hint or two .
If a checkbox is checked, we want to completely clear the Log view every day at 09:00. Here, you’ll need to use a little “hack” to clear the table:
Challenge 1 answer
=IF(I2=TRUE,(SCHEDULE(OVERWRITE_DATA(RANGE2JSON($K$1:$Q$1,$K$2:$Q$2),$A$1:$G$1),"every day 09:00")),"Not clearing log")
We want to send emails every day at 08:59 of the logs to ourselves if a checkbox is checked and only if the user is also clearing the log every day. If they’re not clearing the logs, then the user should see a message explaining why they can’t. You’ll need to use
SEND_EMAIL() and in the body parameter
Challenge 2 answer
=IF(AND(I1=TRUE,I2=TRUE),SCHEDULE(SEND_EMAIL("an_email_address","an_email_address","Logs",RANGE2HTML(A:G)),"every day 08:59"),"Select auto clear to send logs")
In the end, it should look a little like this:
This might be a difficult one, but you have all the tools you need to get it done! We’ll post the answer on 2020-08-13T23:00:00Z just before our final part of the series .
OK, so now you can add checkboxes to your arsenal of dashdash knowledge, and as we said before - combined with buttons and formulas, you can create some powerful and logically complex spreadsheets. If you don’t believe me, just have a look at these templates:
Or, if you want to get a bit more creative, you can check out Sourabh’s article on how to transform checkboxes into radio buttons… Yes, that’s right - you can!
Right, that’s all for today! In the final part of the series we’ll cover input boxes and how to use them in your published spreadsheets. Until then folks, build to your heart’s content !