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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
123117
Frequent Visitor

if under the same value in one column the values are the same in another column

if under the same value in one column the values are the same in another column 

This is what my table looks like: 

 

codecode2country
12348945USA
12348944France
23453666Canada
56787654Africa
56787655Africa

I have codes and their respective countries, I want to check if the same codes have same countries and if not then I wanna flag those codes, codes can repeat by codes2 wont. Code2 can have same codes 

eg: 1234 has two countries; USA and France so I need to flag that but 5678 has the same so it's fine. 

 

desired output: 

 

codecode2countryIndicator
12348945USADifferent
12348944FranceDifferent
23453666CanadaOK
56787654AfricaOK
56787655AfricaOK

 

Please help

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @123117 ,

 

You can try this:-

Indicator =
VAR result =
    COUNTROWS (
        FILTER (
            'Table',
            'Table'[code] = EARLIER ( 'Table'[code] )
                && 'Table'[country] <> EARLIER ( 'Table'[country] )
        )
    )
RETURN
    IF ( ISBLANK ( result ), "Ok", "Different" )

 

Samarth_18_0-1664271312915.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

4 REPLIES 4
Samarth_18
Community Champion
Community Champion

Hi @123117 ,

 

You can try this:-

Indicator =
VAR result =
    COUNTROWS (
        FILTER (
            'Table',
            'Table'[code] = EARLIER ( 'Table'[code] )
                && 'Table'[country] <> EARLIER ( 'Table'[country] )
        )
    )
RETURN
    IF ( ISBLANK ( result ), "Ok", "Different" )

 

Samarth_18_0-1664271312915.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

Hi

 

thanks!

 

I'm trying and I'm getting this error

 

EARLIER/EARLIEST refers to an earlier row context which doesn't exist.

@123117 Please create a column instead of measure.

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

this works! thnx

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors