- Goal: Add numerous filters to charts based on use cases defined below
Context
We are a business that books doctors appointments for patients and allows patients to reschedule appointments at their will. Our database gets populated with all bookings. Whenever a patient reschedules a booking, the old booking is still an entry in the database, but it has a rescheduled_booking_uuid field now containing an id that references a normal booking id. In other words, all columns that have a null value is reschedule_booking_uuid are the final booking. Once we remove any bookings that have reschedule_booking_uuids, we get the total count of bookings on our site.
In addition, our booking status can be "no show," "canceled," "confirmed," and "completed" where confirmed means we have confirmed it with the doctor's office, and completed where the patient has gone to the doctors and completed the appointment.
We do cosmetic bookings and medical bookings. When patients book, we classify their main reason for the visit, e.g. annual physical, dermatology, etc., all of which I want to group into "Medical" as well as Botox visits / other "Cosmetic" appointments.
I'm trying to create a dashboard for our company to show:
total bookings made per week, per month, etc.
break down by booking type "completed," "canceled," "no show" etc. - this is the status column in our table
break down by visit types i.e. "Cosmetic" vs. "Medical"
Goal 1: add a broad range of filters to charts. how do I do this? I can add it to queries but don't know how to bring in filters to my charts after querying only once
I've been able to create some of these filters in tables but essentially none of them in a chart. I query the data and filled my table with myquery.data, in addition to setting the chart to be myquery.data. I added a filter to the table which successfully filters the table, but when I set the chart data to be table1.data, it is the complete dataset, not the filtered dataset.
I have made a second query where I do the filtering in the query and then set my chart to be query2.data, but this seems like an unelegant option. You'd run two queries, not 1.
Goal 2: Add columns / breakdown chart by week of year
Furthermore, I've made use of the created_at column, which is a date-time column based on when the customer creates the appointment (not the date of the appointment, but when they booked it on our site). We are a start up and want to know how much traffic we are getting on a weekly basis. In Microsoft Excel, I can make use of the WeekNum function, but I'm not sure if/how to bring these values into Retool. For example, I want to group all of the appointments by the week that they were booked, so we can see over the course of the year how many bookings are being made on our site by week / by month. This is something that I can do easily in Microsoft excel but am really struggling with on Retool.
Goal 3: sort data into Medical / Cosmetic columns
Last, I want to group our bookings into Medical / Cosmetic. Once again, I know how to make a column in Excel based on whether another column, namely visit_reason, contains the words "botox" or "cosmetic," then it is a Cosmetic Visit, otherwise it is a medical visit. I think I should do a custom column and make it {{currentSourceRow.visit_reason.includes("Botox")}} but also not sure how to check for multiple visit reasons here. And this statement will return true/false rather than "Medical" or "Cosmetic." Maybe I need to make another column then checking whether this column returns true or false.
Any help would be greatly appreciated. I don't have JSON code to share but any that you can help me put together would be greatly, greatly appreciated. Thank you!