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
RIBUZ
Frequent Visitor

Show number of coincidences between two columns

Hello Comunity,

 

I have the folllowing DAX code that is working perfect but would like it in Power Query code. I a more familiar with DAX that's why I had no sucess.

Example.png

Coincides = 
VAR ManualString = SUBSTITUTE ( 'Table'[Manual Serial], " ", "_" )
VAR Length1 = COALESCE ( LEN ( ManualString ), 1 )
VAR T1 = GENERATESERIES ( 1, Length1, 1 )
VAR T2 = SELECTCOLUMNS ( T1, "@Item1", MID ( ManualString, [Value], 1 ) )
VAR T3 = GROUPBY ( T2, [@Item1], "@Count1", COUNTX ( CURRENTGROUP ( ), 1 ) )
VAR CorrectString = SUBSTITUTE ( 'Table'[Correct Serial], " ", "_" )
VAR Length2 = COALESCE ( LEN ( CorrectString ), 1 )
VAR T4 = GENERATESERIES ( 1, Length2, 1 )
VAR T5 = SELECTCOLUMNS ( T4, "@Item2", MID ( CorrectString, [Value], 1 ) )
VAR T6 = GROUPBY ( T5, [@Item2], "@Count2", COUNTX ( CURRENTGROUP ( ), 1 ) )
RETURN 
    SUMX ( 
        T6,
        VAR T7 = FILTER ( T3, [@Item1] = [@Item2] )
        VAR Count1 = MAXX ( T7, [@Count1] )
        VAR Count2 = [@Count2]
        RETURN
            MIN ( Count1, Count2 )
    )

Thank you

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @RIBUZ ,

 

Please try this custom colum.

List.Count(List.Intersect({Text.ToList([Manual Serial]),Text.ToList([Correct Serial])}))

vcgaomsft_0-1677121367714.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

1 REPLY 1
v-cgao-msft
Community Support
Community Support

Hi @RIBUZ ,

 

Please try this custom colum.

List.Count(List.Intersect({Text.ToList([Manual Serial]),Text.ToList([Correct Serial])}))

vcgaomsft_0-1677121367714.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

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.

Top Solution Authors
Top Kudoed Authors