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
gefragt vor 2 Jahren260 Aufrufe
1 Antwort
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
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen