How to add a Metric control to choose between Units or Percentage?

ifelse statemts don’t allow aggregates so my calculated field that I want to use in a parameter doesn’t work.

This is what I have now:

ifelse(${Metric}=“units”, {units}
, ${Metric}=“Percentage”, {percentage}
, {units}
)

Where percentage is:
percentOfTotal(sum({units}))

Does anyone have any workaround?

Try this

ifelse(in(‘units’,${Mertic}),{units},

in(‘Percentage’,${Mertic}),{percentage},1
)

1 Like

Gives me the following error:
Expression in(“units”,${Metric}) for function in has incorrect argument type in(String, String). Function syntax expects ‘in(<COMPARABLE_TYPE>, <COMPARABLE_TYPE>)’
‘in(<COMPARABLE_TYPE>, <COMPARABLE_TYPE>, <COMPARABLE_TYPE>)’.

Can you paste your calculation.

ifelse(in(‘units’,${Metric}),{units},
in(‘Percentage’,${Metric}),{percentage},1
)

Hi @Manuel_Garcia

Is your parameter multiple values? If not go back to your first calculation and add an aggregation to units.

ifelse(${Metric}=“Percentage”, {percentage}
, sum({units})
)
1 Like