I have a string parameter for the month in the dashboard, but I want it to default to the current month when someone opens the dashboard. I knew that we can do it with date datatype but I wasn’t able to do the same with string type. Can you please help here…
Hi @hellosai321, I don’t believe you can set the parameter to a dynamic month, but you can set the default to a static Month (Ex: Always default to January). The following may work as a potential work-around:
All visuals below contain Dummy data
Update the month parameter to have the default value “This Month” (Can label this however you like, but it will be static). For example:
Month Parameter
Create a calculated field to only display data for this month when the control is set to the default “This Month” (Or whatever you set the default to in step 1).
If the parameter is single select:
ifelse
(
${Month}="This Month" AND Date>= truncDate("MM",now()), {Date}, // Control is set to (Default) "This Month" -> only include dates that are in this month
isNull(${Month})=TRUE, Date, //Control is set to "Select All" = show all dates
${Month}= left(toString(formatDate(Date, "MMM-dd-yyyy")),3), Date, //show all dates that fall into the selected month; can customize here as needed
NULL // Otherwise do not display any data that does not fall into the conditions above
)
If the parameter is multi-select:
ifelse
(
in("This Month",${Month2})=TRUE AND Date>= truncDate("MM",now()), {Date}, // Control is set to (Default) "This Month" -> include dates that are in this month
in(NULL,${Month2})=TRUE, Date, //Control is set to "Select All" = show all dates
in(left(toString(formatDate(Date, "MMM-dd-yyyy")),3),${Month2})=TRUE, Date, //show all dates that fall into the selected month(s); can customize here as needed
NULL // Otherwise do not display any data that does not fall into the conditions above
)
Set the calculated field NULL format to “1/1/1900” (Or any arbitrary and unique date; can not be before 1/1/1900):
a. Click on the ellipses next to the calculated field on the left-hand side of the page, and select “Format” → “More formatting Options” → “Null values”.
b. Then Select “Show custom” and type “1900/1/1” in the text box.
Format Options
Update NULL Format
Add a filter to the visual to filter for when the calculated field date is after the date selected in step 3. For example:
This should default the Month Control/parameter to “This Month” and filter the visual to only reflect data for this month as default. As well as adjust according to whatever the user has selected in the Month Control.
EX 1 - single select
EX 2 - single select
EX 3 - single select
When using the multi-select parameter you may notice a red exclamation mark next to the control, but the solution still seems to work
I followed the steps you provided, but despite selecting multiple values in the parameter, I don’t see multiple options in the controls. I’m not sure about what could be causing this issue.