Set a parameter in custom sql

Hi!
I created a PostgreSQL dataset through custom SQL and added a parameter called ‘siteid’ so that my dashboard users can filter their relevant site IDs and then view their data:

image

image

However, when trying to create the dashboard, the user can only choose the default value:

image

Can you help me solve this problem? I have already read everything in the user guide. Thank you!

@shirakoresh, i think here is what’s happening in your scenario. You have created siteid as dataset parameter and set its default value to 89. When dashboard is executed, it is passing 89 as parameter to your dataset and bringing data to dashboard that is related to site 89 and hence you can see only 89 as drop-down value. If you do not want the filter control drop down to be restricted by the default value, you can remove the default value and then drop-down will show all sites available in your dataset for users to select.

@DeepakS Thank you for your answer!
when i’m trying to delete the default value, i’m getting an error:
image

Do you have any other ideas? I still want the data to load only after my user chooses the site ID since the data is quite heavy.

@shirakoresh you have parameters in two places, dataset parameter and analysis parameter. In dataset, when defining parameter, you include a default value that is a must. In analysis, when you are defining a parameter, you can leave the default value blank and map this parameter to the dataset parameter.
Let me know if this doesn’t help.

Hi! @DeepakS thank you for your answer! I deleted the default value from the analysis parameter, but i’m still getting only the same default value from the dataset parameter in the dropdown:
image

Hello @shirakoresh,

Can you please check if your dataset parameter is mapped with the analysis parameter? You can see unmapped dataset parameters on the analysis parameters

On this case, I created the parameter in the dataset like this

image

And this is my Custom SQL, as a direct query.

image

For the parameter in the analysis I created a new dataset with the distinct values for the segments in SPICE.

When creating the analysis based on the customer dataset, you should see the unassigned dataset parameter as in the first screen shot. Go to the map parameter and select Create new

image

When you add the control to the sheet, dont forget to also add it using the same dataset with the distinct values.

With this setup you should be able to open the analysis with the query that is launched against the filtered dataset not returning anything (or you can add a default of your liking)

And when you select a value from the control, then you should see the results returned by the parametrized query.

I hope this helps!

Kind regards,
Andres

Hi! @andres007
Thank you for your answer!
My field is not a sring, but an integer (ID) - so I can’t put n\a in the default value, and I can’t set it as a dynamic default (I can only put string fields there).
What can i do?

Tnx

Hi,

I created a parameter with a integer key using an integer as default and works correctly.

image

In the dataset I added a numeric key, next to the name of the segment and use that in the dynamic default.

Then add the control using the dataset and the column that has the integer

This is how it looks like on the analysis.

I hope this helps!

Hi @andres007 !
I’m not sure what i’m doing wrong, but it’s not working in my case…

and still, I only see the default value from the dataset parameter:

image

Thank you again for all of your help,
Shira

Hi,

Can you check if you have the parameter itself linked to a dataset field?

Kind regards,
Andres.

Hi again @andres007
yes, it is:

Shira

That is very strange, can you try creating a parameter that is not mapped to the dataset parameter and check if you see the list from the dataset?

The problem is that I have to apply a filter to the dataset because it’s too large. I retained the ‘organization Id’ filter in the dataset, specifically when the default is 79.
However, I created a new parameter that isn’t directly linked to any dataset parameter, which filters the site Id. Now I am able to see all the relevant sites under my organization Id:
image

Hello,

I understand the need for the filter, I was just checking if there was something odd with the dataset and showing it as a parameter, which you confirmed it is working as expected.

Have you tried removing the parameter mapped to the filter and start again from the unmapped parameter? If this would not work, maybe try creating a new analysis with only the dataset that needs to be filtered, add the dataset with the filters and see if when you add the parameter as a control to the analysis it works.

Let me know how it works!

Kind regards,
Andres.

Hi!
Yes, I’ve tried to unmap the parmeter and map it again, I’m getting the same result…
I’m not sure what you mean by creating an analysis with only one dataset - this analysis is with one dataset that all of it need to be filtered. Can you try and explain me?

Thank you!
Shira

Hello,

I just recorded a small video on how I made this work.

ezgif.com-video-to-gif (2)

If you cannot make it work following these steps then this question may be difficult to answer through the community forum, and we need to dive deeper in your specific use case.

If this does not solve your specific problem, I will message you privately to discuss possible solutions and approaches.

Kind regards,
Andres.

1 Like

Hi @andres007, please send me a private message so we could talk more about my use case. Thank you!

Hi @shirakoresh @andres007 , did you guys solve this problem?

Yes, the post that is marked as a solution works as expected.

Thanks for replying, can you check my post too if it’s possible?