How to Select multiple related columns in add calculated fields in Quicksight parameter using ifelse ?

0

Hello everyone,

I have a parameter 'type' in a table and it can have multiple values as follows -

  1. human
  2. chimpanzee
  3. orangutan

I have 3 columns related to each type in the table -

  1. human_avg_height, human_avg_weight, human_avg_lifespan
  2. chimpanzee_avg_height, chimpanzee_avg_weight, chimpanzee_avg_lifespan
  3. orangutan_avg_height, orangutan_avg_weight, orangutan_avg_lifespan

So if i select the type as human, the quicksight dashboard should only display the three columns -

  1. human_avg_height, human_avg_weight, human_avg_lifespan

and should not display the following columns -

  1. chimpanzee_avg_height, chimpanzee_avg_weight, chimpanzee_avg_lifespan
  2. orangutan_avg_height, orangutan_avg_weight, orangutan_avg_lifespan

I created the parameter type and in the add calculated fields I am trying to use ifelse to select the columns based on the parameter selected as follows -

ifelse(${type}='human',{human_avg_height}, {human_avg_weight}, {human_avg_lifespan},{function})

I also tried -

ifelse(${type}='human',{{human_avg_height}, {human_avg_weight}, {human_avg_lifespan},{function}})

And -

ifelse(${type}='human',{human_avg_height, human_avg_weight, human_avg_lifespan},{function}})

But none of it is working. What am i doing wrong ?

AWS
asked 2 years ago255 views
1 Answer
0

To achieve this usecase, you can use 3 calculated fields in your visual:

height

ifelse(${type}='human',{human_avg_height},
${type}='chimpanzee',{chimpanzee_avg_height},
${type}='orangutan',{orangutan_avg_height},
NULL)

weight

ifelse(${type}='human',{human_avg_weight},
${type}='chimpanzee',{chimpanzee_avg_weight},
${type}='orangutan',{orangutan_avg_weight},
NULL)

lifespan

ifelse(${type}='human',{human_avg_lifespan},
${type}='chimpanzee',{chimpanzee_avg_lifespan},
${type}='orangutan',{orangutan_avg_lifespan},
NULL)

In the visual, you can use these fields - height, weight, lifespan that would change depending on the type parameter.

Please try the above and let me know if it helps. Thank you!

AWS
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions