SQL -> DATA ( JSON ) -> True & False switchboxes

I have a query that works on RETOOL - this query define one field data with different TRUE & FALSE data. On this data field
an example of the long field is this
"enable_cash_payments":true,"enable_enable_refund":false

From this data or true and false i want to create switch with on and off to review settings on the database.

How i could continue with this ?
For now i'm till the query and don't understand how i can transform PARTS of the data field to read out and transform to switchboxes.

Hello @DHE,

To implement conditional querying based on a switch value, follow these steps:

  1. First, create a dynamic query that adapts to the switch state. For example:
const isSwitchOn = switch1.value;
let sqlQuery = `
  SELECT
    *
  FROM
    data_visualization_dashboard
`;

if (isSwitchOn) {
  sqlQuery += ` WHERE CAST(average_customer_rating AS FLOAT) > 4.5`;
}

return sqlQuery;

Next, execute this query in a new query block and set up an event handler as shown in the attached screenshot.


1 Like