Select Different Granularity Data From Same Table Based on Filter Value

Hi,

I have table with a column ‘data_granularity’ which has values ‘grain1’ and ‘grain2’. My Quicksight dashboard has a filter/parameter “Filter1” and I want to achieve a functionality

if a user selected 1 or more values of Filter1, then query sent to my Redshift cluster should look like below

select * from table where data_granularity = 'grain2'

If there is no value selected in Filter1 then the query should look like

select * from table where data_granularity = 'grain1'

Hi @NeerajGautam

Are you trying to apply user selected filters along with data granularity filter … like below .

When #Filter_Values >=1
select * from table where data_granularity = ‘grain2’ and filter_column in ( filter_values)

When #Filter_Values =0
select * from table where data_granularity = ‘grain1’ and filter_column is null

If you could provide actual usecase it will be more helpful to get the context .

Thanks
VInod

Hi @apjvinod

Yes something similar. Below is the actual use case

When #Filter_Values >=1
select * from table where data_granularity = ‘grain2’ and filter_column in ( filter_values);

When #Filter_Values =0
select * from table where data_granularity = ‘grain1’;

1 Like

Hi @NeerajGautam

Have you looking into the new passing parameters to a dataset?

Hi,

I can’t use Passing Parameter functionality because I want my dataset to be in SPICE for faster dashboard performance. I don’t want to use LIVE datasource (connected to my Redshift cluster) since it will slow down the queries drastically and will not meet my customer’s data retrieval requirements.