Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Set parameter default value to first/top value in the list?
Arif shah
<p>Hi,</p>
<p> </p>
<p>I have a Date parameter which is fetching dates from the database. I have sorted the dates in descending order. I want to set the default value to the top value/data in the list. How can I do this?</p>
<p> </p>
<p>Arif</p>
Find more posts tagged with
Comments
Matthew L.
<p>Hello Arif,</p>
<p> </p>
<p>To set default values in a parameter list dynamically you need to query the database to determine what the value is you are needing to set as the default value.</p>
<p> </p>
<p>To do this, we pre-query the data set in the parameters "getDefaultValueList" and use scripting to return the value we are looking for (ex: topValue).</p>
<p> </p>
<p>Attached is an example that pre-queries the database, iterates through the data rows, makes a comparison on date values, and assigns the highest value to a variable. This value is then returned on the last line of the script in the parameters "getDefaultValueList" method to set the default value.</p>
<p> </p>
<p> </p>
Arif shah
<p>Hi,</p>
<p> </p>
<p>Thanks for the example. Just a question. Why do we need to iterate through all rows? I was wondering if we can send some kind of query to get the max date and assign that to the default value of parameter (though I don't know how to do that)</p>
<p> </p>
<p>Arif</p>
Matthew L.
<p>Arif,</p>
<p> </p>
<p>You could modify the query and do an "ORDER BY columnName DESC" to have it order by the top value and then just pull that value without iterating through each row (See attached).</p>
Arif shah
<p>Hi Matthew,</p>
<p> </p>
<p>This default value has been working excellent until I had a dataset that was updating the query through parameter binding. I am passing the session user from parameter to the dataset through property binding. I am updating the where clause of the dataset query through property binding.</p>
<p> </p>
<p>when I try to set the default value of another parameter that calls this dataset, the default value is not set. Can you please help me set the default parameter value through script when the dataset is updating its query through property binding</p>
<p> </p>
<p>Syed</p>
Matthew L.
<p>Is this a cascading parameter or a completely separate parameter field that you are trying to change the default options of?</p>