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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Bertenvanloover
Frequent Visitor

How to Count rows that contain certain text string and current cell value

Hi, I could use some help finding a way to do the manipulation below in Power Query:
I want to create a custom column "Times_Edited" that counts the total times a Filename got "Change Editing Required" or "Editing Required".

 

I tried this one, but I presume that my [Filename]=[Filename] is the culprit.
= Table.AddColumn(#"Replaced Value1", "Times_Edited", each Table.RowCount(Table.FromRecords({[TransitionName] = "Change Editing Required" || [TransitionName] = "Editing Required" ,[Filename]=[Filename]})))


Purpose: this table shows a history log of changes to the status of Documents. This column would be used as a metric on how often a file is send back for editing. (potentially a DAX procedure is a better choice in comparison to a separate column?)

Thanks!!

 

Related to:
https://community.powerbi.com/t5/Power-Query/How-to-find-text-from-list-in-cell-and-return-that-text...

https://community.powerbi.com/t5/Power-Query/Find-Text-from-List-in-Rows-with-same-ID-as-current-row... 

 

FilenameTransitionNameSubmittedDateTimes_Edited
1Send for Approval22/02/2023 11:001
1Change Editing Required22/02/2023 11:011
1Approved22/02/2023 11:021
2Send for Approval22/02/2023 11:050
2Approved22/02/2023 11:060
3Send for Approval22/02/2023 11:003
3Editing Required22/02/2023 11:023
3Send for Approval22/02/2023 11:033
3Change Editing Required22/02/2023 11:053
3Approved22/02/2023 11:103
3Change Editing Required11/09/2023 09:113
1 ACCEPTED SOLUTION
6677028
Frequent Visitor

Send You.

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Removed Columns" = Table.RemoveColumns(Source,{"Times_Edited"}),
#"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each if[TransitionName] ="Change Editing Required" or [TransitionName]= "Editing Required" then 1 else 0),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Filename"}, {{"Count", each List.Sum([Custom]), type number}}),
#"Merged Queries" = Table.NestedJoin(#"Removed Columns", {"Filename"}, #"Grouped Rows", {"Filename"}, "Removed Columns", JoinKind.FullOuter),
#"Expanded Removed Columns" = Table.ExpandTableColumn(#"Merged Queries", "Removed Columns", {"Filename", "Count"}, {"Filename.1", "Count"}),
#"Removed Columns1" = Table.RemoveColumns(#"Expanded Removed Columns",{"Filename.1"})
in
#"Removed Columns1"

View solution in original post

1 REPLY 1
6677028
Frequent Visitor

Send You.

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Removed Columns" = Table.RemoveColumns(Source,{"Times_Edited"}),
#"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each if[TransitionName] ="Change Editing Required" or [TransitionName]= "Editing Required" then 1 else 0),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Filename"}, {{"Count", each List.Sum([Custom]), type number}}),
#"Merged Queries" = Table.NestedJoin(#"Removed Columns", {"Filename"}, #"Grouped Rows", {"Filename"}, "Removed Columns", JoinKind.FullOuter),
#"Expanded Removed Columns" = Table.ExpandTableColumn(#"Merged Queries", "Removed Columns", {"Filename", "Count"}, {"Filename.1", "Count"}),
#"Removed Columns1" = Table.RemoveColumns(#"Expanded Removed Columns",{"Filename.1"})
in
#"Removed Columns1"

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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