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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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