String month parameter default to current month

Hi All,

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…

Thanks,
Sai

1 Like

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

  1. 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

image

  1. 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
    )
    
  1. 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

    image

    Update NULL Format

    image

  2. Add a filter to the visual to filter for when the calculated field date is after the date selected in step 3. For example:

    Filter

  3. 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

    image

    EX 2 - single select

    image

    EX 3 - single select

    image

    When using the multi-select parameter you may notice a red exclamation mark next to the control, but the solution still seems to work

    EX 4 - multi-select

I hope this helps! Please feel free to reach out if you have any additional questions.

Hi @Kelseykl ,

Thank you for your response.

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.

Hi @hellosai321,

Can you verify that the following match:

  1. your parameter is setup as so for multi-select:

  2. The “month” control is setup with:

  • Control Options → Dropdown - multiselect
  • “Hide Select all …” is de-selected

If the above match then I would recommend trying:

  1. Reset the control
    image
  2. Delete the control, and re-create it from the parameter

hi @hellosai321 ,

did the solution provided by Kelseykl work for your issue? if it does, please help us mark the solution. thank you.

kind regards,
Wakana