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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors