Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gianmarco
Helper IV
Helper IV

IF condition + WHERE

Dear All,

i have the following table:

FruitCityPreferred
BananaNY0
Kiwinullnull
AppleRome1
Orangenullnull
GrapePhilly0

 

I need to create a conditional column for which: IF City = null THEN City where Preferred = 1 ELSE City

Desired result as follows:

 

FruitCityPreferredNEW COLUMN
BananaNY0NY
KiwinullnullRome
AppleRome1Rome
OrangenullnullRome
GrapePhilly0Philly

 

 

Thank you a lot
gianmarco

1 ACCEPTED SOLUTION
ChiragGarg2512
Solution Sage
Solution 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))
return
IF(q1[City] = "null", _v, q1[City])
 
Thank You.

View solution in original post

2 REPLIES 2
ChiragGarg2512
Solution Sage
Solution 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))
return
IF(q1[City] = "null", _v, q1[City])
 
Thank You.
ray_aramburo
Super User
Super 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?

 





Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.