I am trying to add ifelse logic using a parameter (multi value) and it is throwing an error saying incorrect argument type. can anyone please help with this?
ifelse(${TimePeriod}=‘Monthly’, {year_month}, {year_week})
I am trying to add ifelse logic using a parameter (multi value) and it is throwing an error saying incorrect argument type. can anyone please help with this?
ifelse(${TimePeriod}=‘Monthly’, {year_month}, {year_week})
Hello @Lasya hope this message finds you well!!
When working with multi-value parameters, you need to use functions that handle arrays, such as contains()
, instead of directly comparing the parameter to a single value. The ifelse
function you are trying to use needs to be adjusted to check if the parameter contains the desired value. Here’s an example of how you can do this:
ifelse(contains(${TimePeriod}, 'Monthly'), {year_month}, {year_week})
In this example, contains(${TimePeriod}, 'Monthly')
checks if the TimePeriod
parameter contains the value ‘Monthly’. If it does, it returns {year_month}
; otherwise, it returns {year_week}
.
Please, tell me if it works for u
Thanks for your response!
But, I still see the error saying
Expression {{argumentName}} for function {{functionName}} has incorrect argument type {{incorrectArgumentType}}. Function syntax expects {{functionSignature}}.
Hi @Lasya
Based on what you are trying to do it appears the choice of a parameter that is Multi-Value looks wrong.
I presume your selections are like Monthly, Daily, Weekly. Quarterly etc and you can select one option and your calculated field behaves accordingly. If you define your parameter as multi-value it means you can select more than one option, for example Monthly and Weekly together. In that case what does the calculated field supposed to do?
So, you first have to re-create your parameter as a Single value parameter. It does not mean it can not have a list of selections. It can have a list of selections but you can only select one value at a time.
I have provided an example below:
Parameter definition:
Parameter Control Definition:
Once this is set your original ifelse logic itself should work. If there are still issues share the details if your calculated field with the error message
Regards,
Giri
Hello @Lasya, I wanted to check in since we have not heard back from you. Are you able to follow-up with some of the questions that @Giridhar.Prabhu asked above?
Also, instead of using contains, you will want to use the in function when using multi-value parameters.
ifelse(in('Monthly', ${TimePeriod}), {year_month}, {year_week})
If select all is an option in the control as well, then to check for that you need to do this:
in(NULL, ${TimePeriod})
That returns true when All is the value selected in the dropdown.
I agree with Giri though that this seems like a situation where you would want to use a single value parameter, rather than a multi value parameter.
If we do not hear back from you in 3 days, we will close out this topic. Thank you!
Hi @Lasya,
Since we have not heard back, I’ll go ahead and close out this topic. However, if you have any additional questions, feel free to create a new post in the community.
Thank you