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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
lovetolearn
New Member

How do I combine the data of two columns and prioritise data from one?

I have data spanning over 4 years from a lead generation system. At some point a data field called "State" was used and later they started using another field called "Province".

What I have - two columns with some data, some blank fields and sometimes a value in both columns.

what i have.png

I would like to create a third column where I combine the data from the first two columns, but in instances where both columns have data, I want the data from "Province" to be in the Combined column and discard the value from "State".
what I want.png

 

I know how to combine data, but I don't know how to end up with only the single values when there are two values per row.

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @lovetolearn ,

 

You can try the formula like below:

Col = 
IF (
    'Table'[State] = BLANK ()
        && 'Table'[Provice] = BLANK (),
    BLANK (),
    IF (
        'Table'[Provice] <> BLANK ()
            && 'Table'[State] <> BLANK (),
        'Table'[State],
        IF (
            'Table'[State] = BLANK ()
                && 'Table'[Provice] <> BLANK (),
            'Table'[Provice],
            'Table'[State]
        )
    )
)

vhenrykmstf_0-1648461659982.png

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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
v-henryk-mstf
Community Support
Community Support

Hi @lovetolearn ,

 

You can try the formula like below:

Col = 
IF (
    'Table'[State] = BLANK ()
        && 'Table'[Provice] = BLANK (),
    BLANK (),
    IF (
        'Table'[Provice] <> BLANK ()
            && 'Table'[State] <> BLANK (),
        'Table'[State],
        IF (
            'Table'[State] = BLANK ()
                && 'Table'[Provice] <> BLANK (),
            'Table'[Provice],
            'Table'[State]
        )
    )
)

vhenrykmstf_0-1648461659982.png

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

Thank you for this solution, it worked perfectly.

Do you know how I can accomplish this with an M Query so I can add it as an automatic step whenever I import updated data?

 

lovetolearn_0-1655008582093.png

 

amitchandak
Super User
Super User

@lovetolearn ,

 

a new column in dax = coalesce([State], [province] )

 

In power query

if [State] = null then [province] else [province]

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandakThanks for the reply. The logic seems right but it doesn't quite work. This is my result:

 

Screenshot 2022-03-22 224958.png

 

Screenshot 2022-03-22 225137.png

 

Screenshot 2022-03-22 225200.png

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors