Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Grouping file types in a new column

Hi All,

I am creating a column that groups file types that are less important and excluding the types I want to keep.
I managed this using  the following code at the bottom, I am looking for a better way to do this something like:

 

 

exclude filetypes IN {"zip","doc","pdf"}.

 

 


Here is my existing code that I later convert to a list that is used in a merge colomns. This works but find this is not optimal if I later want to add file types.

Any assistance kindly appreciated.

 

 

  = Table.AddColumn(#"Converted to Table", "Other File Types", 
  each if Text.StartsWith([Column1],"doc") or 
  Text.StartsWith([Column1],"zip") 
    or Text.StartsWith([Column1],"pdf") 
    or Text.StartsWith([Column1],"xls") 
    or Text.StartsWith([Column1],"dwg") 
  then null else [Column1], type text)

 

 

 

  •  = Table.AddColumn(#"Converted to Table", "Other File Types", 
      each if List.Contains({"zip","doc","pdf"},[Column1],(x,y)=>Text.StartsWith(y,x,Comparer.OrdinalIgnoreCase)) then null else [Column1], type text)

2 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion
     = Table.AddColumn(#"Converted to Table", "Other File Types", 
      each if List.Contains({"zip","doc","pdf"},[Column1],(x,y)=>Text.StartsWith(y,x,Comparer.OrdinalIgnoreCase)) then null else [Column1], type text)
    • Anonymous's avatar
      Anonymous
      Not applicable

      thanks wdx223_Daniel 
      That is exactly what I was looking for and I learnt something today!