Forum Discussion
Power Query: Count specific values in a column
- Nov 14, 2019
You may add custom column with this formula
Generated script will be
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Added Custom" = Table.AddColumn( Source, "NumberOfSeparators", each List.Count(Text.Split([A],">"))-1) in #"Added Custom"Please check the sample in attached file.
Thanks for the answer!
I tried implementing that but I could not get I to work.
In which context (line of code) would I have to use that?
#"Previous Step" = List.Count(Text.Split([ColumnName],">"))-1
or
#"Previous Step" = Table.AddColumn(#"Respective column", "Desired Output", each if List.Count(Text.Split([ColumnName],">"))-1 else null),
Or am I doing something horribly wrong? Sorry - I am not what you would call an expert here.
You may add custom column with this formula
Generated script will be
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Custom" = Table.AddColumn(
Source,
"NumberOfSeparators",
each List.Count(Text.Split([A],">"))-1)
in
#"Added Custom"
Please check the sample in attached file.
- RaMa87Nov 18, 2019Copper Contributor
SergeiBaklan Thanks! Had to modify a bit, since I am importing from external text files but it did work out in the end:
#"Step name" = Table.AddColumn(#"Previous step", "New Column name", each List.Count(Text.Split([Column with information],">"))-1),
- SergeiBaklanNov 18, 2019Diamond Contributor
RaMa87 , you are welcome. Yes, above was just small sample to illustrate how the function works, not exact patter.