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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors