How to use multiple data sources in one table based on a condition on a date column?

Hi! I am trying to reference two data sources in one table based on a condition on a date column. One data source has the historical data and one has the current data. The data are from different resources so I can't combine them in the same original query.

So I have two queries now with the same columns

  • queryHistoricalData: date, value
    • 2023-07-01, 100
    • 2023-08-01, 120
    • 2023-09-01, 90
  • queryCurrentData: date, value
    • 2023-10-01, 130

I want to create a table that shows the date and the value, using queryHistoricalData when the date column is less than current date, and using queryCurrentData otherwise. What is the best way to achieve this?

Thank you.

Hello, welcome to the community.

you can add one more js query.

in that query you can write some js to judge which query you should return.
I think you may use moment library which is integrated in retool.

and use this js query as data source of table.

thank you! I am able to get it working with a js query.