Forum Discussion

Bertenvanloover's avatar
Bertenvanloover
Frequent Visitor
3 years ago
Solved

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 Requir...
  • 6677028's avatar
    3 years ago

    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"