How to add parameter?

Hi Team,

I want to write a calc with using of parameter, but I’m getting error, could you please help me to resolve this error, see the below formula

ifelse(${MetricName}=‘Cost To Serve’,sum({metric_fact}),

    ${MetricName}='Spend Under Management',avg({metric_fact}),

    ${MetricName}='Preferred Supplier Spend',avg({metric_fact}),

'others')

Here MetricName is parameter and metric_fact is the measure,

could you please let me know where can do the mistake

Thanks & Regards

Chaitanyakumar M

Thanks & Regards,

Chaitanyakumar N

Hi @Cnagabhairava,

Hope this message finds you well! I believe you might be getting an error due to the syntax of your calculated field. The ifelse function follows the below format:

ifelse(if, then [, if, then …], else)

With that in mind, I would try putting those other two MetricName statements within a bracketed list. Let me know if this helps!

1 Like

Could you please help me to write correct calc

When I remove the metric and put text field then calculation is working, but I want to show metric information only, so please help me in this issue

Hi @Cnagabhairava,

Apologies for the delay in response! I was wrong about you needing to wrap the other if conditions in brackets. It is just shown that way so users are aware that multiple conditions can be within the function.

Although this is from my own example, I think this calculated field structure below should fulfill your use case:

Wrapping all of the if checks in sumOver’s make it so you do not run into misaggregation errors while getting your desired result. The bracket represents the desired partition of the calculation which is completely optional. Please let me know if this helps!

Hi WLS-Luis, thank you for your Answer

1 Like