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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Datasource CSV File Folder > Delete old Data creates expression.error

Hi There,

 

I have 2 different Folders with CSV Files for every day.

 

Folder A

> A-2017-01-01

> A-2017-01-02

Folder B

> B-2017-01-01

> B-2017-01-02

 

This files in each folder are merged together and have a relation between folder A and folder B, everything is working fine.

 

But the files are created everyday and I only need the last 2 weeks.

 

So I thought I could delete the old csv files which are not needed anymore.

 

But when I do that is says :

 

expression.error the key didn't match any rows in the table

 

But for me it looks like its searching for entrys that are used to be in the old csv files but I just want it do forget about the old csv files.

 

Is this somehow possible?

 

Thank you in advance.

4 REPLIES 4
MarcelBeug
Community Champion
Community Champion

Probably the name of an old file is hard coded in one of your queries. Prime suspect would be a query "Sample Binary", which is one of the objects created when the "Combine Binaries" functionality is used to combine files from a folder.

 

You can adjust that code so it points to the first (selected) file in the folder.

For instance:
SampleBinary = Source{0}[Content]

where "Source" is the name of the previous step.

 

This behaviour was adjusted (for new combine binaries) in the May 2017 upgrade, as follow up on an idea raised by yours truly.

Specializing in Power Query Formula Language (M)
Anonymous
Not applicable

Hi MarcelBeug,

 

sorry for the late reply.

 

My "SampleFile" looks like this in advanced editor (german, Quelle = source):

 

let
    Quelle = Folder.Files("C:\perfdata"),
    #"C:\perfdata\_perfdata_2017-04-05 csv1" = Quelle{[#"Folder Path"="C:\perfdata\",Name="perfdata_2017-04-05.csv"]}[Content]
in
    #"C:\perfdata\_perfdata_2017-04-05 csv1"

But I dont have any other previous step, so how should I do this here?

 

Thanks for any hint!

This interests me.  Let me see if I understand your issue generically: your source file(s) name(s) is/are regularly changing (we assume the structure is always identical)... 

 

and so are you invoking the Refresh or are you changing data source and doing a new Get Data?

 

 

www.CahabaData.com

So "Quelle" is your previous step and the solution would:

 

let
    Quelle = Folder.Files("C:\perfdata"),
    SampleBinary = Quelle{0}[Content]
in
    SampleBinary
Specializing in Power Query Formula Language (M)

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.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors