+ Reply to Thread
Results 1 to 13 of 13

New Data to ADD rows to Query table

  1. #1
    Registered User
    Join Date
    07-18-2021
    Location
    Texas
    MS-Off Ver
    2013 and 2016
    Posts
    11

    New Data to ADD rows to Query table

    I need to add a new row to a query-bound table with each update of the query. Currently, new values overwrite the current values. I would like new time-dependent values to be in an added table row.
    Can this be done? I found an old post with VBA code that claims to do it, but it wouldn't run because a compiler error was reported to be in it and I can't find the forum post again to verify.
    S

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: New Data to ADD rows to Query table

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    07-18-2021
    Location
    Texas
    MS-Off Ver
    2013 and 2016
    Posts
    11

    Re: New Data to ADD rows to Query table

    Alan:
    "Let me know if that works for you"??
    Apparently I'm missing something. I don't see any recommendation. Are you asking me to upload the workbook? If so, I don't believe I can do that,
    Is there a procedure for appending data to a new table row (not replacing old data) upon query refresh?
    S

  4. #4
    Valued Forum Contributor
    Join Date
    06-23-2021
    Location
    Romania
    MS-Off Ver
    2021, 365 v 2208
    Posts
    722

    Re: New Data to ADD rows to Query table

    Hi,
    There is a way. You can use the append facilities from query editor. But, without a sample workbook with no confidential information, I'm afraid I cannot be more helpful.
    Diana Tanase


    If the solutions offered helped you to solve your problem, then mark the thread as SOLVED (thread tools in the top menu) and you can click on * to add reputation to those who helped you, as a way to say thank you !

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: New Data to ADD rows to Query table

    Yes, you can attach a sample (desensitised) workbook.

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    07-18-2021
    Location
    Texas
    MS-Off Ver
    2013 and 2016
    Posts
    11

    Re: New Data to ADD rows to Query table

    Thank you for responding. Attached is an example workbook and here's what I'm trying to do:
    The RAW DATA sheet is a table (RAW_DATA) in this example. In actual practice it is a table created from a query to a file or, in some instances, a URL.
    The CURRENT VALUE sheet has the table CURRENT_VALUE containing info and some arithmetic from RAW_DATA.
    I would like to create a table that adds a new row to a table each time the RAW_DATA table is updated or "refreshed" as a query. It can/should be on a new sheet (named it Data HISTORY in this example). Each time the RAW_DATA is refreshed/updated there will be an updated DATATIME.
    Is the generation of a running time-based history table of the CURRENT_VALUEs feasible? If so, can the table be manually cleared and started again from a new Row 0 (after the row containing the column titles)?
    Attached Files Attached Files

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: New Data to ADD rows to Query table

    Am I understanding correctly, each time you add new data to your raw data table, you wish to create a new query and save it (close and load) to a new sheet. You will not be updating the original query output. If I am not understanding you correctly please advise what you want.

  8. #8
    Valued Forum Contributor
    Join Date
    06-23-2021
    Location
    Romania
    MS-Off Ver
    2021, 365 v 2208
    Posts
    722

    Re: New Data to ADD rows to Query table

    When table in Raw Data is changing you need a row with calculation in Change value to be add as a new row in History?
    In this case:
    HTML Code: 
    If that's OK then you can add this action as worksheet change event to "Raw Data" worksheet.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-18-2021
    Location
    Texas
    MS-Off Ver
    2013 and 2016
    Posts
    11

    Re: New Data to ADD rows to Query table

    tanasden,
    I'm not sure I follow your question... When the date in RAW DATA changes, I want the values in CURRENT VALUES that are calculated from RAW DATA to become and added row in DATA HISTORY.
    I will try your example to see what it does.
    Thank you.

  10. #10
    Registered User
    Join Date
    07-18-2021
    Location
    Texas
    MS-Off Ver
    2013 and 2016
    Posts
    11

    Re: New Data to ADD rows to Query table

    Each time RAW_VALUES table is updated, I want the values in CURRENT_VALUES that are calculated from RAW_DATA to become an added row in DATA _HISTORY.
    RAW_DATA in actual practice is a query to a file or a URL that contains its data. CURRENT_VALUES are the sum and and average of some parameters in RAW DATA and the time the data was measured. When CURRENT_VALUES gets updated from RAW_DATA, I want a row to be added to DATA_HISTORY table.

  11. #11
    Valued Forum Contributor
    Join Date
    06-23-2021
    Location
    Romania
    MS-Off Ver
    2021, 365 v 2208
    Posts
    722

    Re: New Data to ADD rows to Query table

    Hi,
    I added the macro as an event on change to the worksheet "Raw_Data"
    I hope it meets your expectations.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    07-18-2021
    Location
    Texas
    MS-Off Ver
    2013 and 2016
    Posts
    11

    Re: New Data to ADD rows to Query table

    Thank you tanasedn!
    It works with the table as is on the CURRENT VALUES sheet. I must now change that table to a Query Table that periodically gets new data. I don't believe that will change the VBA code you placed in your xlsm file since that table is buffered by RAW DATA and none of the DIM or other statements relate to the CURRENT VALUES table, but I'm not sure. I hope you don't mind if I get back to you if I have trouble.

  13. #13
    Valued Forum Contributor
    Join Date
    06-23-2021
    Location
    Romania
    MS-Off Ver
    2021, 365 v 2208
    Posts
    722

    Re: New Data to ADD rows to Query table

    Quote Originally Posted by Stan21 View Post
    I hope you don't mind if I get back to you if I have trouble.
    No, I'm not! You're welcome!

+ 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. Sorting Pivot Table Pulling from Power Query Data Table
    By perkyparker in forum Office 365
    Replies: 1
    Last Post: 05-22-2021, 03:02 PM
  2. [SOLVED] Match values from a query table to a table with fixed rows and columns
    By tferreiraqtl in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-15-2019, 07:05 AM
  3. [SOLVED] Power Query: Extract data from table after other rows are filtered
    By JimDandy in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-25-2017, 02:10 AM
  4. Replies: 0
    Last Post: 10-11-2013, 11:03 AM
  5. Replies: 0
    Last Post: 12-05-2012, 03:48 PM
  6. Replies: 0
    Last Post: 09-05-2012, 06:12 PM
  7. Query Data in hidden rows/columns with Query Box
    By VincetOmnia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2009, 10:53 PM

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