Ifelse() with parameter syntax

I am trying to simply create a calculated field using ifelse() but keep getting a syntax error. when I look through other people’s formulas they all have the same structure as what I am using. What am I not seeing? Here is my formula:

ifelse(${TimeFrame}=“Monthly”, truncDate(“MM”,{Renewal_Due_Date})))

The portion highlighted as error is just the parameter name.

My end goal is to create a formula that allows me to switch the date aggregation on charts and tables and I would like to swap between month, quarter, year and ytd. Any additional support in the rest of the code would be appreciated as well.

Hi @bmike4

You are missing the ELSE part of the statement. (its expecting 3 parameters)

Example:
ifelse(${testparameter}=‘Monthly’, truncDate(‘MM’,{Order Date}),{Order Date})

Regards,
Ramon

2 Likes

ifelse(${TimeFrame}=“Monthly”, truncDate(“MM”,{Renewal_Due_Date}),{Renewal_Due_Date})
returns the same error.

Hey Ramon,

Thanks for your reply. However, it doesn’t seem to make a difference in my instance. I’ve remade the parameter and even rewrote them in a different dataset and analysis and this still didn’t work.

ifelse(${TimeFrame}=“Monthly”,truncDate(‘MM’,{Renewal_Due_Date}),${TimeFrame}=‘Quarterly’, truncDate(‘Q’,{Renewal_Due_Date}),${TimeFrame}=‘Yearly’,truncDate(“YYYY”,{Renewal_Due_Date}))

Does it have to do with the parameter configuration? Might it be a string list = string?

Attached are the parameter setting i have selected.

Thanks!

That would be it @bmike4 - it must be single value parameter.

Regards,
Ramon