Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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 FILE | ROW NUMBER |
001 | 1 |
001 | 2 |
001 | 3 |
002 | 1 |
002 | 2 |
002 | 3 |
003 | 1 |
003 | 2 |
and so on.
Any idea on how I do this?
Thanks in advance,
Ana
Solved! Go to Solution.
Hi @AFra ,
sure, here is the screenshot:
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
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 😕
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?
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:
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
Hi @AFra ,
sure, here is the screenshot:
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!
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 , 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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
71 | |
57 | |
38 | |
36 |
User | Count |
---|---|
81 | |
67 | |
61 | |
46 | |
45 |