Forum Discussion
gianmarco
2 years agoHelper IV
IF condition + WHERE
Dear All,
i have the following table:
| Fruit | City | Preferred |
| Banana | NY | 0 |
| Kiwi | null | null |
| Apple | Rome | 1 |
| Orange | null | null |
| Grape | Philly | 0 |
I need to create a conditional column for which: IF City = null THEN City where Preferred = 1 ELSE City
Desired result as follows:
| Fruit | City | Preferred | NEW COLUMN |
| Banana | NY | 0 | NY |
| Kiwi | null | null | Rome |
| Apple | Rome | 1 | Rome |
| Orange | null | null | Rome |
| Grape | Philly | 0 | Philly |
Thank you a lot
gianmarco
gianmarco , If this is the data then this column formula should work:
Column =var _v = CALCULATE(Max(q1[City]), FILTER(q1, q1[Preferred] = 1))returnIF(q1[City] = "null", _v, q1[City])Thank You.
2 Replies
- ChiragGarg2512Solution Sage
gianmarco , If this is the data then this column formula should work:
Column =var _v = CALCULATE(Max(q1[City]), FILTER(q1, q1[Preferred] = 1))returnIF(q1[City] = "null", _v, q1[City])Thank You. - ray_aramburoSuper User
Just a question to give you the best logic and solution. When Preferred = 1 the expected outcome should always be "Rome" or are you expecting other cities as well?