Create date parameter in quicksight, if date='week' then extract week_number.

Using the parameter, I’m trying to do calculate daily, weekly, monthly calculation. But when ‘week’ is selected, I’d like to extract week_number instead for trunking date to week.

Below is the similar sample.

https://democentral.learnquicksight.online/#Analysis-TipsAndTricks-Calculation-Switch-Date-Aggregation

Calculated Field:
ifelse(
${Periodstarting}=‘Day’,truncDate(“DD”,{date_time}),
${Periodstarting}=‘Week’,decimalToInt(dateDiff(truncDate(“WK”,truncDate(“YYYY”,{date_time})),{date_time})/7)+1,
${Periodstarting}=‘Month’,truncDate(“MM”,{date_time}),
truncDate(“YYYY”,{date_time})
)