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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.