Forum Discussion

zouweyhd's avatar
zouweyhd
Frequent Visitor
4 years ago
Solved

if else statement between 2 Tables

hello everyone

how can i build an if else colomn between to Tables that have a colomn in common ( which is the Invoice number )

and i cannot merge the 2 Tables because both are huge ( each contains about 400K lines and 40 column at least )

 

your help will be highly appreciated 

  • Hi zouweyhd

     

    RELATED is a DAX function. You should use it in a calculated column in data model rather than in a custom column in Power Query Editor.

    In Data view, click New column and enter below code in the formula bar. 

    Nettowert =
    IF (
        RELATED ( 'table2'[VGTYP] ) IN { "H", "K", "N", "O" },
        [NETWR] * -1,
        [NETWR]
    )
    

     

    The RELATED function requires that a regular relationship exists between the current table and the table with related information. You need to create a relationship on the common column in advance. And ensure that each row has only one related "VGTYP" value in the other table. 

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.

3 Replies

    • zouweyhd's avatar
      zouweyhd
      Frequent Visitor

      i have built this statement but im not sure if it will do 

      • v-jingzhang's avatar
        v-jingzhang
        Community Support

        Hi zouweyhd

         

        RELATED is a DAX function. You should use it in a calculated column in data model rather than in a custom column in Power Query Editor.

        In Data view, click New column and enter below code in the formula bar. 

        Nettowert =
        IF (
            RELATED ( 'table2'[VGTYP] ) IN { "H", "K", "N", "O" },
            [NETWR] * -1,
            [NETWR]
        )
        

         

        The RELATED function requires that a regular relationship exists between the current table and the table with related information. You need to create a relationship on the common column in advance. And ensure that each row has only one related "VGTYP" value in the other table. 

         

        Best Regards,
        Community Support Team _ Jing
        If this post helps, please Accept it as Solution to help other members find it.