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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
fred65
Helper I
Helper I

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)

 

 

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

 = 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)

View solution in original post

2 REPLIES 2
wdx223_Daniel
Super User
Super User

 = 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)

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors