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
westillusinguse
New Member

Count how many times a string from one column appears in a the column of a different table

I need a PowerBi solution. I need to count how many times the string in column "Modes" appears in the table column of "Companies Modes of Transportation". The "Companies Modes of Transpartation" column is a multi select column so I cannot easily do a countrow funtion because it will not be a 1 to 1 match. 

 

A lot of solutions that I have found have been looking for a specific word but I need to count how many all of the words in the "Modes" column appears.

 

I could do this in Excel by using the * but I cannot figure out how to replicate something like this in PowerBi for all of the words in the "Modes" column.

 

westillusinguse_1-1701963944861.png

westillusinguse_2-1701963963663.png

The example below should return:

Airplane: 4

Car: 2

Truck: 4

Rail: 6

Boat: 4

 

 

6 REPLIES 6
parry2k
Super User
Super User

@westillusinguse no worries, click transform data -> select the column that need splitting -> click split by delimited (screen shot below) -> enter delimiter (semicolon) -> click advanced options -> select rows -> click ok

 

and this will do it.

 

parry2k_0-1701971273254.png

 

parry2k_1-1701971356052.png

 

 

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@westillusinguse it can be done, but as a best practice, I would recommend splitting the column to the rows in the PQ and from there everything should be super simple. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

If I split it up then it would disrupt other data points that were calculated because it would add additional rows. Is there anyway to incorporate the containstring funtion and pile onto the formula?

 

Something like: =Countrows(Filter(Table,(ContainsString(Table,Column,"Train"))), Countrows(Filter(Table,(ContainsString(Table,Column,"Train"))), etc.

Hi @westillusinguse 

 

Would this work as a calculated column in your Modes table?

 

 

Count 2 = 
    COUNTROWS(
        FILTER(
            'Companies',
            CONTAINSSTRING( 'Companies'[Company Modes of Transportation], [Mode] )
        )
    )

 

 

or 

Count 3 = 
VAR _Mode = [Mode]
RETURN
    CALCULATE(
        COUNTROWS( 'Companies' ),
        CONTAINSSTRING( 'Companies'[Company Modes of Transportation], _Mode )
    )

I can't get either of them to work because PowerBI cannot recognize Mode at the end of the formula.

If you are creating a calculated column in the Modes table, you should have no problem.

 

Search column for mode of transportation.pbix

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.