Skip to main content
Susan Clark 님이 #Tableau Prep에 질문했습니다

Hello, I'm new to Tableau Prep and appreciate this is probably very basic.

 

Please can someone help with this calculated field I'm trying to create? I've read multiple Q&A's saying this can't be done in Tableau Desktop so I'm thinking it's not possible in Prep either !?

 

Ideally I'm wanting one calculated field to display:

 

IF [usage_type] CONTAINS ('Box') or ('envelope') THEN "Usage"

ELSIF [usage_type] CONTAINS ('DBS') THEN "DBS"

ELSE null

END

 

Tableau Prep is flagging the first 'THEN' as invalid syntax

 

I basically want to filter out the 3 (Box, envelopes & DBS) but at the same time group Box & envelopes and keep DBS as separate.

 

Any help would be greatly appreciated. Thank you.

답변 3개
  1. 2023년 4월 13일 오후 12:03

    Hi @Susan Clark​ ,

     

    The format for contains function is as follows

     

    CONTAINS(string, substring)

     

    Check if the below formula works,

    IF CONTAINS ([usage_type],'Box') or CONTAINS([usage_type],'envelope') THEN "Usage"

    ELSIF CONTAINS ([usage_type],'DBS') THEN "DBS"

    ELSE null

    END

     

    Regards,

    Ajay

    Please upvote and mark as Best Answer, if it helps you :)

0/9000