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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Deletion of rows in multiple sheets

I'd like to automate some reports. 

I have numerous excel files into a folder. Each excel files have multiple sheets. 

 

Ideally : 

- All excel sheets should have the first row and the last row deleted. 

- Then first row set as header 

 

Could someone please give me some guidance how to create a function which would perform the above on all excel sheets? 

 

Thank you, 

 

Lorenna 

 

1 ACCEPTED SOLUTION
v-danhe-msft
Employee
Employee

Hi @Anonymous,

Based on test, you could refer to below steps in query editor:

Sample excel files in my folder:

2.PNG 

1.Get data from one of the excel files(here is A) and delete the first and last row.

1.PNG

 

2.Modify the code in advanced editor.

Before modify:

3.PNG

Insert this code and modify the source:

(para as text) as table =>
let
Source = Excel.Workbook(File.Contents("C:\Users\danielh\Desktop\Parameter\"&para&".xlsx"), null, true),

After modify:

4.PNG

Here the query becomes a function and you could enter the name of the excel file and all of them will have the first row and the last row deleted.

1.PNG

 

Regards,

Daniel He

 

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-danhe-msft
Employee
Employee

Hi @Anonymous,

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-danhe-msft

 

Thank you very much for the solution ! 

 

v-danhe-msft
Employee
Employee

Hi @Anonymous,

Based on test, you could refer to below steps in query editor:

Sample excel files in my folder:

2.PNG 

1.Get data from one of the excel files(here is A) and delete the first and last row.

1.PNG

 

2.Modify the code in advanced editor.

Before modify:

3.PNG

Insert this code and modify the source:

(para as text) as table =>
let
Source = Excel.Workbook(File.Contents("C:\Users\danielh\Desktop\Parameter\"&para&".xlsx"), null, true),

After modify:

4.PNG

Here the query becomes a function and you could enter the name of the excel file and all of them will have the first row and the last row deleted.

1.PNG

 

Regards,

Daniel He

 

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.