How to Create a Third Table Chart in QuickSight to Identify Patients with Appointments Only in Specific Date Ranges

Hello QuickSight Community,
I need assistance with creating a third table chart in QuickSight to identify patients with appointments only in specific date ranges. Here’s the scenario:
Dataset Fields:

  • Start Date (Appointment Date)
  • Patient Account Number
  • Patient Name

Current Setup:
I have two table charts:

  1. Left Chart: Filtered by Start Date (Jan 1 - Feb 29, 2024), displaying appointments during this period.
  2. Right Chart: Filtered by Start Date (March 1 - March 31, 2024), displaying appointments during this period.

Objective:
Create a third table chart to show the difference between the first two charts. In other words, I want to display patients who appear in the first chart but not in the second chart.
Approach:

  1. Logic for Comparison: We need to compare the patient names between the two date ranges to identify the difference.
  2. Calculation or Logic: Can we achieve this by creating a calculated field or applying a logical condition within QuickSight.
  3. Single Tab Setup: To facilitate user control over date ranges, incorporate a date control feature where users can select their desired date ranges (e.g., a week, 15 days, a month, etc.).

Assistance Needed:

  1. Guidance on whether a calculated field is necessary or any alternative logic to achieve the objective.
  2. Instructions on how to implement this in a single tab, incorporating a date filter or control for user flexibility in selecting date ranges.
    @DylanM
    Any insights or suggestions on the above points would be greatly appreciated. Thank you!

Hi @Abhishek_24
what datasource type do us use?
Are both tables out of the same dataset?
BR

Hi @ErikG ,
Database Connection through PostgreSQL
Yes, Both Tables are from the same dataset.

If my desired goal can be achieved using just one table, that would be preferable. I am willing to discard both of my current tables.

two ideas i have in mind.

  1. create 2 filtered datasets (left/right) and join on Patient name
  2. create a select statement

Could we explore another approach, perhaps using a calculated field? The steps mentioned—creating two filtered datasets and joining on Patient name, followed by creating a select statement—how does the first approach contribute to achieving my objective?

How about creating a dataset from a SQL query like:

WITH 
set_a as (
  SELECT patient_account_number
  FROM table_name
  WHERE date >= timestamp '2024-01-01' and
      date < timestamp '2024-02-29'

),
set_b as (
  SELECT patient_account_number
  FROM table_name
  WHERE date >= timestamp '2024-03-01' and
      date < timestamp '2024-03-31'
)
SELECT
  patient_account_number
FROM set_a
WHERE patient_account_number NOT IN (SELECT patient_account_number FROM set_b)

The limitation is that you cannot use the same table view for all three tables, but you can use multiple datasets in the same dashboard.

1 Like

I understand you would like the functionality to allow adjusting the date ranges?

This could be easily achieved by expanding the date range in the example SQL query (Eg, for the whole of 2024). You can then add a filter to the visual, and pin filter Controls to the sheet.
This will allow the viewer (user) to more dynamically adjust the dates required, providing they are within the date range selected in the SQL query.

Additionally, you could amend the SQL query date range to use a relative date period, such as an equivalent to ‘Year to Date’.

Of course, if the dataset is relatively small, you may choose to skip the date range in the SQL query.

Reply if you need help amending to a relative date range

Let me try this with query and let see where it will take me.
I will update you on the same. for more help
Thankyou.