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

Counting how many times certain word is in column per row

hi

 

I have tried to understand how to calculate next

 

I have roughly 5000 rows in table1

I have column "Info requests" in my table and it includes data like

 

caseID                           info requests

11111                            

11112                            responded;

11113                            responded; waiting response

11114                            responded; responded; cancelled

11115                            cancelled; responded;

 

Now I want to create new column which includes information how many times responded has been visible for each caseID

my expectation is to have next kind of info

 

caseID                           info requests                                             IR responded

11111                                                                                          

11112                            responded;                                               1

11113                            responded; waiting response;                  1

11114                            responded; responded; cancelled;            2

11115                            cancelled; responded;                              1

 

I do not know how to do it, can you help?

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

@Crisse ,

 

You may also add a custom column.

List.Count(Text.Split([info requests], "responded")) - 1
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-chuncz-msft
Community Support
Community Support

@Crisse ,

 

You may also add a custom column.

List.Count(Text.Split([info requests], "responded")) - 1
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
PattemManohar
Community Champion
Community Champion

@Crisse  Please try using "Split Column" and "Group By" options to achieve this in Power Query Editor.

 

Here is the M-code generated by using those two steps on the sample data.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMgQBJR0lpVgdCMcIyClKLS7Iz0tJTbGGCxujCJcnZpZk5qUrQESKUxHqTFDUIVjJiXnJqTk5yEaaApUihJHtjAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [CaseID = _t, InfoRequests = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"CaseID", Int64.Type}, {"InfoRequests", type text}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"InfoRequests", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "InfoRequests"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"InfoRequests", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type1", {"CaseID", "InfoRequests"}, {{"CountResponded", each Table.RowCount(_), type number}}),
    #"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([InfoRequests] = "responded"))
in
    #"Filtered Rows"

image.png





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




@Crisse 

 

As a calculated column in DAX you can use

 

Column =
PATHLENGTH ( SUBSTITUTE ( [info requests], "responded", "|" ) ) - 1

pathtocount.png


Regards
Zubair

Please try my custom visuals

Thank You, I manage to get at least some data 😉

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.