Forum Discussion
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:
| Date | Cost | ID | True/False |
| 01.01.2022 | 500 | 1234-5678 | 1 |
| 02.01.2022 | 1000 | 8765-4321 | 0 |
| 03.01.2022 | 1500 | 1234-5678 | 1 |
Table2:
| ID | Category |
| 1234-5678 | Others |
| 8765-4321 | Prod |
| 5273-9275 | Others |
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
- amitchandakSuper User
lkshck , if you need one column , else break the logic
new column in Table 1
new column =
var _max = maxx(filter(Table2, Table2[ID] = Table1[ID] ), Table2[Category])
returnSwitch( True(),
Table[True/False] =, "Business" ,
_max ="Others", "Others",
"Platform"
)refer 4 ways to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8 - SpartaBICommunity 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.- lkshckHelper 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.
- SpartaBICommunity 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")