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
Anonymous
Not applicable

How to get the Flag value by matching two columns?

Hi All,

 

The sample data is attached below. The column "PG Original" is the main column to be considered.

Step 1 - For Countries which have "MOSE Service" in PG original, Should be matched with "MOSE Service" in PG Derived and Flag should be 1, for rest flag should be 0.

Step 2 - For Countries which dont have "MOSE Service" data in PG Original, should be compared by their PG Values & MOSE Service.  (say) For Country "Austria", there is no MOSE Service data. For that country, flag should be 1 for "Drives"(PG Original) & "Drives"(PG Derived) and "Drives"(PG Original) & "MOSE"(PG Derived), and rest as 0. Similary for Motors service.

 

CountryPG OriginalPG DerivedFlag
AustriaDrives ServiceDrives Service1
AustriaDrives ServiceMOSE Service1
AustriaDrives ServiceMotors Service0
ArgentinaMOSE ServiceDrives Service0
ArgentinaMOSE ServiceMOSE Service1
ArgentinaMOSE ServiceMotors Service0
AustriaMotors ServiceDrives Service0
AustriaMotors ServiceMOSE Service1
AustriaMotors ServiceMotors Service1

 

I need the flag value to be created as shown in the above table. Please provide the solution/approach to resolve this.

Thanks in advance !!

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @Anonymous 

You can create a custom column with below code:-

FLag =
IF (
    OR (
        Country_data[PG Derived] = Country_data[PG Original],
        Country_data[PG Derived] = "MOSE Service"
    ),
    1,
    0
)

Output:-

Samarth_18_0-1628237326748.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

1 REPLY 1
Samarth_18
Community Champion
Community Champion

Hi @Anonymous 

You can create a custom column with below code:-

FLag =
IF (
    OR (
        Country_data[PG Derived] = Country_data[PG Original],
        Country_data[PG Derived] = "MOSE Service"
    ),
    1,
    0
)

Output:-

Samarth_18_0-1628237326748.png

 

Thanks,

Samarth

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.