Photo by Kinga Cichewicz on Unsplash

Multiple Rooms in Coda → Part 2

Select the days with rooms that fit your criteria

In our previous blog we shared the code snippet that allowed us to find the rooms within the budget for a certain number of people. We continue by adding a date picker to only get a sub set. This is important to:

  • have a user friendly solution
  • speed up the calculation

We apply a date logic as shown in this blog using date pickers. This limits the amount of rows for which we need to calculate available rooms. The mother table contains all the dates plus the available rooms and via a button we fill out a second table with the matching rooms using the date values as filter combined with AddRow(). This goes really fast.

calculations for a sub set

Preparations to book a room

Once we have the results on our screens, we want to select the combinations that match our preferences. Often a single day shows have multiple combinations. The challenge is to keep the combined rooms together and enable the user to select them easily. We plan for two actions:

  • The available rooms are taken out of the list with available room
  • The rooms are added to a table containing only reservations

As you might remember from a previous blog, I had applied the Max Method to create sample data for a year. Now it is time to use this sample to create a base table that only contains dates and per date the available rooms.

To get there I needed to solve one little issue: some dates don’t have a room available. Instead of disabling the button when no room is available (would have worked as well) I solved it by using an IfBlank(1) and IfBlank(0) .

Adding a row when no room is available.

I took this path to always have a date record in my list. The disable function would result in skipping dates and that is not what we want. The outcome is a table with available rooms and all dates.

all dates with rooms or a zero

Selecting the rooms

Once we see the possible combinations per day, we want to select a combination that fits us. How we end up with this overview, you read below the image. More about this result in my next blog (part 3).

The button outside the main table (n.b. not the one above, but the first image) takes care of two main actions. When the table is still empty, it pushes the selected dates in the table which will result in all available combinations based on a function living in a column. Once the table contains data and has at least one selected date, the same button pushes an other button in the table that brings the selected date related data towards the next table (screenshot above). For this we use the code snippet below.

calculating price and rooms and splitting the combinations

The button outside the table (screenshot below) contains this code.

button code outside table

As you can see it does a bit more than pushing buttons in the table; it also opens the next page and clears the table. The code snippet can be written a bit shorter using If() instead of SwitchIf(). However after a certain time you might forget about the ingenious solutions you once created and you need a bit of help to understand your previous self. The part AvailableRooms.Count()=0 I put there to remind myself that two functions are executed and both are based on a table that is contains rows or is empty (no rows).

Below again the button I wrote about that executes two functions related to the fact the table is empty or not. The name of the button changes accordingly.

How you start

Our next step is to make use of the overview to select the combination of your choice, to bring it to the table that contains all reservations and to take out these rooms for certain dates out of our ‘stock’. How this works, you read in my next blog. The sketch below shows how we relate the tables.

The steps we make from all rooms to reserved room

I hope you enjoyed this article. If you have questions feel free to reach out. Though this article is for free, my work (including advice) won’t be, but there is always room for a chat to see what can be done. Besides you find my (for free) contributions to the Coda Community and on Twitter

My name is Christiaan and I support SMB with calculations (budgets and planning) and I prefer using Coda to get the job done.

Not to forget: the Coda Community provides great insights for free once you add a sample doc.

Christiaan on: Multiple Rooms in Coda → Part 2



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Christiaan Huizer

Christiaan Huizer

I use Coda mainly for planning & calculations of all sorts. Follow me to learn how to Coda with numbers. I blog at least once per week.