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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
GMCMORROW
New Member

Take value from another column if blank

I have 2 SQL tables, customer and address table, that i need to use logic on. 

 

I want to take a value from the address table but if its blank i need to take a value from the Customer table. 

 

Does anyone have an example of a similar query?

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @GMCMORROW ,

 

I have built a data sample,

Eyelyn9_1-1638931499484.png

 

 

You could simply use LOOKUPVALUE():

 

Column = LOOKUPVALUE(BPADDRESS[EXTNUM_0],'BPADDRESS'[BPCNUM_0],[BPCNUM_0],[BPCNUM_0])

 

 

Eyelyn9_0-1638931486512.png

 

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @GMCMORROW ,

 

I have built a data sample,

Eyelyn9_1-1638931499484.png

 

 

You could simply use LOOKUPVALUE():

 

Column = LOOKUPVALUE(BPADDRESS[EXTNUM_0],'BPADDRESS'[BPCNUM_0],[BPCNUM_0],[BPCNUM_0])

 

 

Eyelyn9_0-1638931486512.png

 

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

AlB
Community Champion
Community Champion

Hi @GMCMORROW 

Can you show a sample of the tables? Are they linked by a relationship? How?

How are the values in both tables linked?


SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Hi @AlB

 

Thanks for responding.

 

I have two tables (BPCUSTOMER & BPADDRESS) that are linked by a customer number BPCNUM_0 a unique value on both tables. 

 

I want to take the field EXTNUM_0 from the BPADDRESS table but if its blank I want to take the field BPCNAM_0 from the BPCUSTOMER table. 

 

I hope thats enough data to help!

 

 

 

 

AlB
Community Champion
Community Champion

 

@GMCMORROW 

Always show a sample of the tables; it makes everything easier. This would be best done in power query but if you want it in DAX create a calculated column in BPCUSTOMER:

NewCol =
VAR aux_ =
    LOOKUPVALUE (
        BPADDRESS[EXTNUM_0],
        BPADDRESS[BPCUSTOMER], BPCUSTOMER[BPCUSTOMER]
    )
RETURN
    IF ( NOT ISBLANK ( aux_ ), aux_, BPCUSTOMER[BPCNAM_0] )

 If this doe not work i need a smaple of the tables with an example and the expected result, plus the specification of the relationship (one to many and who filters who?)

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.