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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AFra
Helper III
Helper III

Importe row number from an excel file

Hi all, 

 

I have imported a folder with 150 excel files. I would like to import also the ROW NUMBER for each line of each excel file, so that I get an index column such as : 

EXCEL FILEROW NUMBER
001

1

0012
0013
0021
0022
0023
0031
0032

and so on. 

 

Any idea on how I do this? 

Thanks in advance, 

Ana

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @AFra ,

sure, here is the screenshot:

image.png

And also link to file below: 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

9 REPLIES 9
ImkeF
Community Champion
Community Champion

Hi @AFra ,
if you use the Import from folder - functionality then you should have a query where you transform the data from a sample file. This query is "married" to an automatically generated function which is applied to every row/file within your folder before expanding all the values.

Go to this query and add an index column in there.
This will create what you've requested.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hi @ImkeF , I tried what you suggested, but it doesnt fully work 😕 

AFra_0-1616768553418.png

I have an index column, but it displays a unique number per excel file. For each file (in the picture 11 Angles and ABC are files) I would need an index, from 1 to 200 (because each file contains 200 rows). 

Any ideas?  

ImkeF
Community Champion
Community Champion

Hi @AFra ,

yes, that's not the right place to add the index column. 

It has to sit in the function that your'e executing in the step before:

 

image.png

Find out where it comes from and add the index in there.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Thanks a lot @ImkeFfor your help, but I don't understand what you mean by "it has to sit it the function". I tried to execute the index function before in the steps, but it doesn't change anything. would you be kind enough to show me how to do it? here's a sample of the files (they should be in a folder) : https://we.tl/t-xJiXZIVMvt

ImkeF
Community Champion
Community Champion

Hi @AFra ,

sure, here is the screenshot:

image.png

And also link to file below: 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Thanks a 10000 times! 

AFra
Helper III
Helper III

Hi @amitchandak, thank you for your response. 

I was wondering if there is any possibility to create an index column based on the folder name, so that the count of rouws starts at 1 at every change of name folder. Do you know if it's possible? 

@AFra , I think @ImkeF  , may provide a solution for this

@ImkeF , can you help with this

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
amitchandak
Super User
Super User

@AFra , You might have to create a new column of row number in excel for that. As in the case of folder, transformation is post-merge

 

In power bi You can add index column https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors