How to set up a date range filter using parameters that can be included as Control in a panel

Hello
I have a field in our dataset which is “SignatureDate” and which is a Date/Time field.

I would like to create a date range filter using two paramenters as initial values “StartDate” and “EndDate”.

So far I have been able to create the paramenters, create the filter and set the initial start and end values to these paramenters… but now I would like to add this filter to the Controls of the panel so the user can change the date rage if he wants to.

Problem is that when I create the filter, and I set it up to use the paramenters for the start and end of the date range, I dont see the possibility to add this filter as a control to the panel.

Is there any solution/workaround for this?.

Thanks a lot!

1 Like

Hi @Jlabuelo,

After you create the filter and set it up to use parameters. You will be able to “Add Control” from the parameter. Please refer the below snippet.

image

Hope that helps!

Thank you,
Shravya

So , I assume I will have to create two controls, one for the StartDate and another for the EndDate, right?. If so, how can I set them up in order than EndDate is always >= StartDate and both values are not null?

Yes. We can handle NULLS by setting default values in the parameters. And to set End date > = Start date we need to create a calculated field and then apply that on your visual. But actually after reviewing your use case again i can suggest one way →

We don’t need to create two parameters unless if you have any specific requirements. If you don’t have anything specific, then you can follow below steps -

Step 1 - Create 1 Date parameter and set a default date (It can be anything, previous/this year/day/month…etc)

Step 2 - Add Date filter to your visual and select the Filter type as Relative dates. At the end you can select Date and time from a parameter and select the parameter you have created above.

Step 3 - Here you can add control from the filter itself

Finally it looks like this - Is this expected for you? or please let me know if you still want to choose the first approach if you have any specific requirements?

Date

Please let me know

Thank you,
Shravya

1 Like

Hello Shravya

Thanks a lot for your answer but it is not exactly what I am looking for.

What I need is

a) The user to pass (Using the API) to the Dashboard a date range like

start 2024/02/15 to 2024/03/05

. This date range is applied to a filter so data shown in the visuals of the Dashboard are filtered.
b) AWS QuickSight dashboard (panel) to show all data reflecting in the visuals with information related to that time range of step a).
c) If the user would like to change the date range, already in Quicksight Dashboard, to offer him a control that can allow him to move the date range to another date rage as for example

start 2024/03/15 to 2024/04/21

I mean, the capacity to allow the use to call the Dashboard (Panel) providing the first date range (I thought by using a parameter), but then also allow the user, already with the panel open, to modify that date range by using a control (or other solution).

This is what I am not able to get done.

I have tried to replicate your suggestion, but I am not able to get it to work this way

  1. How can I pass to the Dashboard (using the API) the first Date Range?

  2. Once step 1 is solved. How can I get the user to modify this Date Range in a control??

Thanks

Hi @Jlabuelo, hope these three links help:

Did this solution work for you? I am marking this reply as, “Solution,” but let us know if this is not resolved. Thanks for posting your questions on the QuickSight Community!

Hello, thanks for your reply, but no, this is not exactly what I am looking for.

What I am trying to get is

a) Build a parameter so the Dashboard can receive a Date Range (StartDate & End Date) value from the API.

b) Create a Filter to filter the Dashboard using that parameter.

These two points I am able to build them with no problem and works fine. By doing this I am able to launch the Dashboard using the API and show the visuals with the data filtered by the initial Date Range provided.

But now I want also the Dashboard to offer the possibility to the end user to change the Date Range in the Dashboard itself. So I am trying to :

c) Set the filter (or the parameter) that have been created in step a) or b) as a Control in the Dashboard so, once the Dashboard is shown, the user can manually change in this control another Date Range (StartDate2, EndDate2).

Step c) is what I am not able to do. If I create a filter by using the parameter as it is done in step b), then there is no option to create the filter as control.

Is there any workaround to get this done?

Thanks

Hi @Jlabuelo, thanks for the clarification, one way to accomplish this is using custom coding - listen to QuickSight events:

<!DOCTYPE html>
<html>

<head>
    <title>Basic Embed</title>
    <!-- You can download the latest QuickSight embedding SDK version from https://www.npmjs.com/package/amazon-quicksight-embedding-sdk -->
    <!-- Or you can do "npm install amazon-quicksight-embedding-sdk", if you use npm for javascript dependencies -->
    <script src="./quicksight-embedding-js-sdk.min.js"></script>
    <script type="text/javascript">
        const embedDashboard = async () => {
            const {
                createEmbeddingContext,
            } = QuickSightEmbedding;

            const embeddingContext = await createEmbeddingContext();

            const containerDiv = document.getElementById("embedding-container");

            const frameOptions = {
                // replace the value below with the one generated via embedding API
                url: "<YOUR_EMBED_URL>",
                container: containerDiv,
                height: "700px",
                width: "1000px",
            };

            const contentOptions = {
                onMessage: async (messageEvent) => {
                    switch (messageEvent.eventName) {
                        case 'PARAMETERS_CHANGED': {
                            // messageEvent.message contains all parameters with active values
                            console.log(JSON.stringify(messageEvent.message));
                            break;
                        }
                    }
                }
            };

            const embeddedDashboard = await embeddingContext.embedDashboard(frameOptions, contentOptions);
        };
    </script>
</head>

<body onload="embedDashboard()">
    <div id="embedding-container"></div>
</body>

</html>

Thanks a lot for the answer, but I think the solution is too complex for what is needed.

I think what we are going to do is to not allow the user to send the Date Range using the API to a parameter but to filter the Dashboard by default stablishing the date range to the first of january of the actual year to the date of today, and then allow the user to change the Date Range in a control included in the Dashboard.

Dont know if our initial idea could be sugested somehow in any way to AWS?.
Thanks a lot again for your time and help.

Regards