Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
ValeriaBonini
Partner - Creator
Partner - Creator

If conditions

Hi, I have a table with these columns:

ARTICLE    CATEGORY  MATERIAL

 

I would like to create a new column  "Master Category" with these conditions:

IF CATEGORY='categoryName' and MATERIAL= A or B then MASTER CATEGORY='master1'

IF CATEGORY='categoryName' and MATERIAL='C' then MASTER CATEGORY='master5'

IF CATEGORY='categoryName' and ARTICLE    = 'article name'  then MASTER CATEGORY='master4'

IF CATEGORY='categoryName' and MATERIAL='C' then MASTER CATEGORY='master7'

IF CATEGORY='categoryName' and ARTICLE    = 'something'  then MASTER CATEGORY='master9'

ALL OTHER CASES MUST BE MASTER CATEGORY='Not defined'

Labels (5)
2 Replies
Chanty4u
MVP
MVP

Try this

 

    IF(

        CATEGORY = 'categoryName' AND (MATERIAL = 'A' OR MATERIAL = 'B'),

        'master1',

        IF(

            CATEGORY = 'categoryName' AND MATERIAL = 'C',

            'master5',

            IF(

                CATEGORY = 'categoryName' AND ARTICLE = 'article name',

                'master4',

                IF(

                    CATEGORY = 'categoryName' AND MATERIAL = 'C',

                    'master7',

                    IF(

                        CATEGORY = 'categoryName' AND ARTICLE = 'something',

                        'master9',

                        'Not defined'

                    )

                )

            )

        )

    ) AS

[Master Category];

snibrahim1993
Partner - Contributor III
Partner - Contributor III

Hi @ValeriaBonini 
Please try the below

IF(CATEGORY = 'categoryName' AND (MATERIAL = 'A' OR MATERIAL = 'B'), 'master1',
IF(CATEGORY = 'categoryName' AND MATERIAL = 'C', 'master5',
IF(CATEGORY = 'categoryName' AND ARTICLE = 'article name', 'master4',
IF(CATEGORY = 'categoryName' AND MATERIAL = 'C', 'master7',
IF(CATEGORY = 'categoryName' AND ARTICLE = 'something', 'master9', 'Not defined'))))) AS [Master Category];

Regards, Mohamed Ibrahim.
If this resolves your Query please like and accept this as an answer.