+ Reply to Thread
Results 1 to 10 of 10

Power Query loading sheets inconsistently

  1. #1
    Registered User
    Join Date
    04-21-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    2016
    Posts
    26

    Power Query loading sheets inconsistently

    I have a folder with several workbooks (one per worker) with several identical sheets (one for each 30 day period) created by a macro.

    I have a power query query to pull several of these sheets to create a summary pivot by month.
    My problem is that the first sheet pulls in the way I expect it to, but all subsequent sheets are offset by by a column, as if column "A" which is an index column has been removed.
    So when I go to consolidate the data, it is no longer aligned.

    I have double checked the sheets and they are identical. I have removed any merged cells, but that doesn't seem to be affecting it.

    Any ideas for how to get the data aligned so it pulls into the power query editor like it looks on the worksheet?

    Thanks!

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Power Query loading sheets inconsistently

    PowerQuery is case sensitive so check headers in every table

    "header" and "header " are two different names

    or attach any examples (desensitized)
    Last edited by sandy666; 05-07-2018 at 07:20 PM.

  3. #3
    Registered User
    Join Date
    04-21-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    2016
    Posts
    26

    Re: Power Query loading sheets inconsistently

    The headers are created by the macro, every sheet is identical in structure. I created new files so that I could ensure that nothing was changed and I get the same results.
    Its format the sheet, rename it, add a sheet, format it, rename it, repeat.

    These are the columns in the sheet.
    Cols0.jpg


    These are the columns in power query. As the Case Action changes from the first set of sheets (Case Action Dec 01-thru Dec-30) to the next (Case Action Dec 31 thru Jan 29) everything moves one column to the left.
    Cols1.jpg
    Last edited by armlegx; 05-07-2018 at 07:53 PM. Reason: update

  4. #4
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Power Query loading sheets inconsistently

    Ok, I'll try again: attach desensitized example excel files
    Pictures are useless

    and example result (created manually if needed) what you want to achieve
    Last edited by sandy666; 05-07-2018 at 08:22 PM.

  5. #5
    Registered User
    Join Date
    04-21-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    2016
    Posts
    26

    Re: Power Query loading sheets inconsistently

    OK, here is a desensitized example file, and a file with the outcomes I get when I load the query and the one I desire.
    The outcomes file has the query being used.

    Thanks.
    Attached Files Attached Files

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Power Query loading sheets inconsistently

    Hi armlegx,

    You have two different looking tables on each "Action" sheet. If this were a text file you could filter them out somehow, but merging Excel sheets you need Tables of Data.
    So the rows above 16 on each sheet are pulled into the PQ and confuses the import/merge.

    Either create tables of data on each Action sheet starting at row 16 and pull them in as tables or move the top table over to the right.
    I'm also concerned about any column heading that is the same in or between tables.

    Does this help:
    https://www.excelguru.ca/blog/2015/0...n-power-query/

    Note how Puls has a single table on each sheet and not two..
    Last edited by MarvinP; 05-08-2018 at 12:50 AM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  7. #7
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Cool Re: Power Query loading sheets inconsistently

    You need to revise the result of your VBA or you will have a lot of manual work.
    IMHO you can use "from file" then filter to stay with Action tables. Next remove first 15 rows from each table, promote headers, sort tables for correct order then append and add ID column (in this case: Amy).
    Your vba produce many blank rows what is totally unnecessary for tables.

    Anyway if you do this correctly for all 30 workbooks you need do this only once independently from VBA or changing your Action ranges to tables.

    see attached
    (path is C:\test\ )
    Attached Files Attached Files
    Last edited by sandy666; 05-08-2018 at 07:37 AM.

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Power Query loading sheets inconsistently

    Hi armlegx,

    I have a possible fix/solution. Remove the blank column A on each of your Case Action sheets and rework the second half of your script. Without a blank column A the import seems to not shift columns on the second sheet.

    I think what is happening is, the programmers never considered two tables on the same sheet. There focus is to merge columns with the same spelling in the column head. You don't have official "Tables of Data" so it simply is treated somewhat like a txt file import. When it gets to the second sheet it is trying to match the column head names and can't find one that is null. It then shifts to the first one that has something in it to try to match. The shift happens on the second sheet.


    I wish there was a way/method to delete the first 15 rows on each new sheet that is pulled into the query. I need to study to see if that is possible in M Language.


    The other way to do this is to create a "connection only" for each Action sheet individually and then merge them all to one big merge.

  9. #9
    Registered User
    Join Date
    04-21-2016
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    2016
    Posts
    26

    Re: Power Query loading sheets inconsistently

    Thanks for the suggestions. These process being driven by VBA already - the workbooks are password protected, so I am opening them off of the network and saving them locally without password protection so that power query can read the files. It looks like I have some work to do, but I think removing the first 15 rows when the file is being opened and re-saved should do it.

    The sheet structure made a lot of sense when they were created 4 years ago. It wasn't until last week that it became problematic.

  10. #10
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Power Query loading sheets inconsistently

    First 15 rows and first blank column, so your table should start from A1
    but you can do that in PowerQuery. Choose easier way for you

    edit:
    changing column names should be your last step in PowerQuery
    note:
    I said : Append not merge - in my previous post
    Last edited by sandy666; 05-08-2018 at 01:32 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 04-05-2018, 01:16 AM
  2. error in power query & power pivot
    By Baldev Kumar in forum Excel Charting & Pivots
    Replies: 8
    Last Post: 01-03-2018, 01:34 AM
  3. [SOLVED] Power Query Not loading all Rows from Source File
    By jdriscol in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-21-2017, 04:03 PM
  4. Replies: 7
    Last Post: 07-25-2017, 08:38 AM
  5. Merge Sheets Power Query
    By morerockin in forum Excel General
    Replies: 8
    Last Post: 04-11-2017, 08:17 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1