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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.