Forum Discussion

Keks's avatar
Keks
Frequent Visitor
2 years ago
Solved

Create new column while comparing 2 other

Hi everybody, 
I would like to create a view and/or export for having the abilty to know the exact composition of my articles on the 3 levels of their composition.

ID_ParentID_ChildParent_article_NameArticle_Name
15Lev2_xxxLev3_yyy
26Lev2_zzzLev3_aaa
31Lev1_bbbLev2_xxx
42Lev1_xxxLev2_zzz
27Lev2_zzzLev3_bbb
28Lev2_zzzLev3_ccc
18Lev2_xxxLev3_ccc

 

 

And I would like to be able to do this

Level1Level 2Level 3
Lev1_bbb  
 Lev2_xxx 
  Lev3_yyy
  Lev3_ccc
Lev1_xxx  
 Lev2_zzz 
  Lev3_aaa
  Lev3_bbb
  Lev3_ccc

 

So,
- for level 1 : ID_Parent never exists in ID_Child
- for level 2 : ID_Child may exists in ID_Parent

- for level 3 : ID_Child never exists in ID_Parent

How can I do that ? Do I need 3 columns ? 
1. Article Name Level 1
2. Article Name Level 2 
3. Article Name Level 3 ? 

Can someone please help me?
Thanks in advance for your help

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, Keks 

    You can create columns and try the following DAX

    Level 1 = 
    IF(
        NOT('Table'[ID_Parent] IN VALUES('Table'[ID_Child])),
        'Table'[Parent_article_Name],
        BLANK()
    )
    
    Level 2 = 
    IF(
        ('Table'[ID_Child] IN VALUES('Table'[ID_Parent])),
        'Table'[Article_Name],
        BLANK()
    )
    
    Level 3 = 
    IF(
        NOT('Table'[ID_Child] IN VALUES('Table'[ID_Parent])),
        'Table'[Article_Name],
        BLANK()
    )
    

    Here is my preview:

     

    How to Get Your Question Answered Quickly 

    Best Regards

    Yongkang Hua

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Keks 

    You can create columns and try the following DAX

    Level 1 = 
    IF(
        NOT('Table'[ID_Parent] IN VALUES('Table'[ID_Child])),
        'Table'[Parent_article_Name],
        BLANK()
    )
    
    Level 2 = 
    IF(
        ('Table'[ID_Child] IN VALUES('Table'[ID_Parent])),
        'Table'[Article_Name],
        BLANK()
    )
    
    Level 3 = 
    IF(
        NOT('Table'[ID_Child] IN VALUES('Table'[ID_Parent])),
        'Table'[Article_Name],
        BLANK()
    )
    

    Here is my preview:

     

    How to Get Your Question Answered Quickly 

    Best Regards

    Yongkang Hua

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.