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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
nicoolai
Frequent Visitor

Count how often a list of strings occur in another tables fields

I have two tables:

Table A with a list of identifiers, nothing more.

Table B with a list of TEXT queries.

 

I want to add a column to Table A, that counts how many entries in Table B that contains the identifier (from Table A).

Does this make sense?

How can I do this in power query, in Table A? 

Is this even a good way to get this done? Should I be doing this in some other way?

 

I can't really think of a way to link the tables as Table B is all dynamic free text query logs that MIGHT contain the identifiers from Table A (zero or many times).

1 ACCEPTED SOLUTION
AMeyersen
Resolver I
Resolver I

@nicoolai ,

if the amount of data is fairly small, you can brute force it:

  1. do a cross join from Table A with Table B
    https://learn.microsoft.com/en-us/power-query/cross-join
  2. Expand Table B
  3. Filter "text column contains ID column"
    = Table.SelectRows(#"previous step", each Text.Contains([TableB.LogEntries], [TableA.IDs]))
  4. group by IDs and count rows

Before you try this approach, calculate the number of records the cross join produces ([#Rows TableA] * [# Rows TableB]). If this number is huge (hundreds of millions of rows) this is not going to work.

View solution in original post

2 REPLIES 2
AMeyersen
Resolver I
Resolver I

@nicoolai ,

if the amount of data is fairly small, you can brute force it:

  1. do a cross join from Table A with Table B
    https://learn.microsoft.com/en-us/power-query/cross-join
  2. Expand Table B
  3. Filter "text column contains ID column"
    = Table.SelectRows(#"previous step", each Text.Contains([TableB.LogEntries], [TableA.IDs]))
  4. group by IDs and count rows

Before you try this approach, calculate the number of records the cross join produces ([#Rows TableA] * [# Rows TableB]). If this number is huge (hundreds of millions of rows) this is not going to work.

Vijay_A_Verma
Super User
Super User

Need the sample data for both the tables to provide the right solution.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors
Top Kudoed Authors