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
已提问 2 年前260 查看次数
1 回答
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
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则