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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
Anonymous
Not applicable

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
Anonymous
Not applicable

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
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