Forum Discussion

lkshck's avatar
lkshck
Helper III
4 years ago
Solved

If condition between two tables

Hey,

I want to create a new column which should contain three values ("Business", "Platform", "Others) based on an IF condition. I have two tables:

Table1:

DateCostIDTrue/False
01.01.20225001234-56781
02.01.202210008765-43210
03.01.202215001234-56781

 

Table2:

IDCategory
1234-5678Others
8765-4321Prod
5273-9275Others

 

The new column will be placed in the Table1 and should be based on the following conditions.

1. IF True/False from Table1=1 THEN "Business", ELSE "Platform"

2. IF Category from Table2=Others THEN "Others", ELSE "Platform"

 

Tables have an relationship based on the ID.

  • lkshck 
    Your 2 conditions are colliding.. you need a to combine them so there will be a clear presendence between all the possabilities.
    I took a guess 🙂 but if it's not that, than write to me exactly what is the logic in one nested if of all multipe options.

    Column =
    SWITCH(
    TRUE(),
    Table1[True/False] = 1, "Business",
    RELATED(Table2[Category]) = "Others", "Others",
    "Platform"
    )

6 Replies

  • SpartaBI's avatar
    SpartaBI
    Community Champion

    hey, before making it a little bit more complicated than basic, does in both these tables the ID column is unique? or it is 1 to many from one of them. If 1 to many,  which is the 1 in which is the many?
    If 1 to 1 than I recommend first to join them before bring them in the model for best practice. There is no reason for 1:1 relatioships other then one needs to be in a different storage mode (import vs direct) or security constraints of somekind.  

    • lkshck's avatar
      lkshck
      Helper III

      Hey, so in the Table2 the ID is unique and in Table1 there can be many of the IDs. So it's a 1 to many relationship from Table2 to Table1.

      • SpartaBI's avatar
        SpartaBI
        Community Champion

        lkshck 
        Your 2 conditions are colliding.. you need a to combine them so there will be a clear presendence between all the possabilities.
        I took a guess 🙂 but if it's not that, than write to me exactly what is the logic in one nested if of all multipe options.

        Column =
        SWITCH(
        TRUE(),
        Table1[True/False] = 1, "Business",
        RELATED(Table2[Category]) = "Others", "Others",
        "Platform"
        )