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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
haykp
Helper I
Helper I

How to filter wrong named files?

Dear Forum,

 

Please help with my frist steps.

I want to filter out all files, which does not match to some exact pattern.

I have that patter, which is file should end with  _CW<number>_<year>_<month>_<day>_<time>.csv

all other .csv file which does not end with this format I want to filter out.

 

I have tried multiple options, but cannot solve this issue. These are my files

sales1_res_CW1_2023_05_23_23h23h53s.csv
sales2_res_CW2_2023_04_23_23h23h53s.csv
sales3_res_CW3_2023_03_23_23h23h53s.csv
sales2_res_CW8.csv
sales3_res_CW3_03_23_23h23h53s.csv
sales3_res_CW3_2023_23h23h53s.csv
sales3_res_CW3_23h23h53s.csv

 

I want to filter our during Transform all the files in red color.

Can someone please help me to write M-Query equation for this please.

 

( I have tried End with, but it want exact value)

 

Thanks

Hayk

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @haykp 

 

Download example PBIX file

 

If you split the column by delimiter at every underscore _ then you can remove any blank rows from the final column (see image below) and you're left with the filenames you want.

 

fn1.pngfn2.png

 

Then tidy up by deleting the columns created by the 'split column by delimiter' step.

 

Duplicate the column first if you want to preserve the filenames.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

1 REPLY 1
PhilipTreacy
Super User
Super User

Hi @haykp 

 

Download example PBIX file

 

If you split the column by delimiter at every underscore _ then you can remove any blank rows from the final column (see image below) and you're left with the filenames you want.

 

fn1.pngfn2.png

 

Then tidy up by deleting the columns created by the 'split column by delimiter' step.

 

Duplicate the column first if you want to preserve the filenames.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.