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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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

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
Super User
Super User

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?  

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

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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