Forum Discussion

gerard-kouadio's avatar
3 years ago
Solved

create new column from 2 tables using if function

Hello, I have 2 tables and I want to create a column from the ids of the 2 tables. I want to do something like this:

if id of table 1 = id of table 2, put yes, if no, put No.

NB: there is a many-to-many relationship in the tables

 

Thank you for your help !

6 Replies

  • Mikelytics's avatar
    Mikelytics
    Resident Rockstar

    Hi gerard-kouadio,

     

    Can you please show a picture of the data model as well as explain how you want to visualize it? Which visual do you want to use and which columns do you also want to put into the visual?

     

    Best regards

    Michael

  • Thennarasu_R's avatar
    Thennarasu_R
    Responsive Resident

    Hi,

    Measure=IF(SELECTEDVALUE(TAble1 [ID])=SELECTEDVALUE(TAble2 [ID]),"YES","NO")

    Thanks,
    Thennarasu

  • Hi,

    This could also work:

    Column =
    VAR _Lookup = [Product]
    RETURN
    IF (
    ISBLANK ( LOOKUPVALUE ( Table2[Product], Table2[Product], _Lookup ) ),
    "No",
    "Yes"
    )

  • I finally used this code:
    New colomn = if(ISBLANK(LOOKUPVALUE('Table1'[Id], 'Table1'[Id],Table2[Id])),"Non","Oui")