Results 1 to 3 of 3

Thread: Add Unique Serial No in Power Query.

  1. #1
    Seeker newuser17's Avatar
    Join Date
    Jun 2018
    Posts
    6
    Articles
    0
    Excel Version
    2016

    Add Unique Serial No in Power Query.



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Dear Gurus',

    I am relatively very new to Power Query.
    I run a query to combine excel files from multiple users form a folder. the raw data have same no of columns and same header. the query works like a charm.
    But as a new addition to our process we have to serialize the row data based on two conditions with category id and last used serial no. which means each user's file have category ID and related data, which category id is duplicated in a column multiple time. this scenario i same for every user. i m maintaining the category ID and last used serial no in a separate table in another workbook.

    now what i need to be done is through the power query is while combining the files add a custom column and serialize the data based on the category id and last used serial no. this can be easily done in normal worksheet max if + 1 formula with iteration calculation enabled. but i have no clue how to include this scenario in the power query.

    i have attached few screen shots of my raw data and desired outcome.

    raw data

    Click image for larger version. 

Name:	Raw data after combining.jpg 
Views:	6 
Size:	73.7 KB 
ID:	8089

    last used serial no
    Click image for larger version. 

Name:	last used serial no.png 
Views:	7 
Size:	4.7 KB 
ID:	8090

    desired outcome
    Click image for larger version. 

Name:	Desired outcome.jpg 
Views:	8 
Size:	90.4 KB 
ID:	8091

    I have about 10000 of rows to process on daily basis and i would be much grateful for your help, effort and time. i am using excel 2016 in windows 7 environment with no office 365 subscription.

    thanks in advance.

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,344
    Articles
    57
    Blog Entries
    14
    Excel Version
    Excel Office 365 Insider
    Alright, so yes, we can make this happen. A couple of things though...

    1) I don't believe your sample data/output is correct. (I don't ever say that but...) You've got the last used serial for 1215 as 00789, but in your sample output the first number generated is 000780, not 000790. I only saw this because I calculated your results and it generates two outliers. (Of course, this is why you need Power Query to make sure this doesn't happen to you!)
    2) This technique actually makes use of two custom columns written using formulas, one of which is a Table.AddColumns(). This is not day 1 stuff for Power Query, but if you want to learn it, we teach you how to get comfortable with these kind of functions in our Power Query Academy.

    I've attached the output for you here. Incidentally, the technique I used for this is actually the subject of next week's blog post (which I wrote up a couple of days ago!)
    Attached Files Attached Files
    Ken Puls, FCPA, FCMA, MS MVP

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book M is for Data Monkey, or our new Power Query Recipe cards!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  3. #3
    Seeker newuser17's Avatar
    Join Date
    Jun 2018
    Posts
    6
    Articles
    0
    Excel Version
    2016

    Thanks

    Hi Ken, thanks for your quick reply to my thread, I havent expecting such a early solution for this scenario which I was struggling for weeks.

    Yes. I agree that serial no should be 00790. And I admits that its a mistake or human error. To rectify these issues only Im looking for a reliable solution.

    At the moment I m home and I dont have excel 2016 at home. Once I reach office I will try the solution and let you know.

    Also how can I download the attached file ?
    Thank you very much for the power query academy link and I will definitely follow it up.

    And I just wonder how I came up with a scenario which is going to be on your next blog..

    Thanks anyway..

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •