Error in parsedate for date parameter

Hello,
I have built a Date Parameter for my dashboard. Currently, it’s in STRING format but I want to convert it in the date format. I used parseDate function to convert into the date format but I am getting the below error. Can you please help in resolving this error? Thanks!

Hi @saljain - Welcome to AWS QuickSight community and thanks for posting the question. Can you please share the sample data and expected output. This will help in guiding the right solution.

Regards - Sanjeeb

Hi @saljain

could you remove that part or move it to the end?

BR

1 Like

Thank you for your reply!
Please refer to that attached screenshot for the sample data and expected output. The goal is to create a date parameter for weekly, monthly, quarterly, yearly view. For eg: When the user selects Monthly, the dashboard view is updated to show month level data. Currently, the problem is with this date parameter, the date field that I have built is in string format and I want it in the date format. I am using parsedate function but getting error as stated. Please let em know if you have any questions. Thanks!

That was my mistake. Actually, this is the calculated field and I ams till getting the same error.

Nested ifelse functions. needs to look like this.

Hi I have it in this format only. In my case i just have one condition

ifelse(${Date}=‘Weekly’, parseDate(toString({date_week}),“YYYY-MM-DD”),
${Date}=‘Monthly’, parseDate(toString({date_month}),“YYYY-MM-DD”),
${Date}=‘Quarterly’, parseDate(toString({date_quarter}),“YYYY-MM-DD”),
${Date}=‘Yearly’, parseDate(toString({date_year}),“YYYY-MM-DD”), “”)

Hi @saljain - Can you please replace the parsedate part by the below details.

parseDate(substring({date_week},1,10),'YYYY-MM-DD')


Still getting the same error

Hi @saljain - Ok, in your original formula can you replace default value (“”) to parseDate(“”)

Regards - Sanjeeb


Still getting the same error.

Please look at my previous post. You cannot us ifelse() the way you have done. you need to use nested ifelse() functions to accomplish what you are trying to do.

Hi @saljain - I test with one ifelse and it worked… see the screenshot.

See the data below

Can you try the below code

ifelse({Date} = 'Weekly',parseDate(substring({date_week},1,10),'yyyy-MM-dd'),parseDate(''))

Regards - Sanjeeb

1 Like

I tweaked the code you suggested as I was getting the the string error. This worked!!!
This was super helpful, thank you so much!!

2 Likes