Date Parameter - selecting monthly level

Hi. I have a monthly data, which has a field that contains the month and year.

If I change this field to Date type instead of string, it will be truncated, e.g. anything in 2019/07/* will be truncated to 2019/07/01.

image

I have created a control and parameter to allow users to select the month that they want, called SelectMonth:

image

Here is the filter setting, condition is data should be equal to the SelectMonth parameter:
image

However, this seems to not work as the visuals would always show no data for any of the months, despite there being data. If the filter is disabled, data will be shown.

Can I know what I’m missing? Is it because date parameters can only be set at Day granularity max, and not Month? Thanks.

To add, as a workaround, I have changed the monthly date to string and use string parameter. This way, I’m able to filter the data by month but as a string, instead of date.

Ideally we would like this to be date if possible.

Hi,
You can add a calculated field which consumes the parameter that has been created and also use the function extract or substring to retrieve the year and month. This can later be passed on to the existing filter condition. Please find the document link for substring and extract below:

Thanks @priyanka_gowda , although unfortunately this does not work as it returns the output as integer (if using extract) and string (if using substring).

Hi @sabmz

If Date in your analysis is a date field, then create a datetime Parameter (call it DateParam) and select a static or a dynamic date value (even if it is a date, the control will later be displayed as YYYY MM so that the visual will be filtered for the month selected).

Create a calculated field that will give us 1 for the entire month of any date selected by the parameter, and 0 for any other months:

ifelse(

{Date} >= truncDate(‘MM’, ${DateParam}) and {Date} < truncDate(‘MM’, addDateTime(1, ‘MM’, ${DateParam})),

1, 0

)

Add this calculated field as a filter to the visual and make it equal to 1 (that is, show only the dates in the month selected by the parameter).

Add the DateParam as a control to the sheet and format it as YYYY/MM or in any other way you want.

Hope it helps,
GL