+ Reply to Thread
Results 1 to 31 of 31

Using Powerquery to import data from a website to an Excel spreadsheet.

  1. #1
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Folks,
    Disclaimer – I am not stock picker, expert, investor, data miner or anything like that.
    I am fascinated by how Excel can be used to make time consuming actions, simpler.
    So, with that said:
    I am trying to figure out how to use Power query to extract certain information from a website onto an excel spreadsheet.
    I have uploaded an Excel file to show you the requirements.
    Basically, I want to be able to enter the stock Ticker abbreviation, for any company, from the website www.finviz.com/screener.ashx into cell A1 and have the information that appears, for that stock ticker symbol, appear on the Excel file.
    At the same time, it should also, bring the “Monthly” chart for that stock symbol as well.
    If anyone out there, knows how to do this, and assuming that it is not too much trouble, I’d appreciate the Power query lesson/education.
    Thank you
    Doofus.

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

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Take a look at this link. I use this to track the stocks I own.

    http://www.michael-saunders.com/stoc...ages/info.html
    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
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    My name is Doofus.
    The link, while probably useful to an investment savvy individual, is useless to a nitwit like me.
    You've heard of the Wolf of Wallstreet, but I'm more like the sheep of Sesame's Street.
    What I am after is how to use Powerquery to do what I had outlined.
    Thank you for the link though - one day... if I have any money.... maybe.
    Doofus.

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

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    See if this does what you are asking. It goes to the web site in question and brings up the information from that site for the Symbol you type in M2. You can review the Mcodes for both tables by clicking on View in the PQ Editor and then selecting Refresh All Button. I don't build graph charts so you will need to seek out others for that help.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    It isn't quite what I was after but I will try it.
    In the meantime, if anyone else has any ideas on how to do this, please feel free to show me how.
    Thank you all.
    Doofus

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

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    I have been working on getting the second table imported through Power Query when you select the Ticker. I don't believe you can bring the graphic chart into PQ.

    Attached is the updated file with instructions. It required building a Parameter table in Column A of Sheet2.
    Here is the Mcode for that table which is closed and loaded to a connection only
    Please Login or Register  to view this content.
    Next I input the variable name of the query into the Path of the table I wished to get
    Please Login or Register  to view this content.
    It has been a great learning experience for me to figure this one out.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    First, thank you for taking the time to work on this.
    This is what I am after.
    The chart is not as useful as this.
    So, lets forget the graph.
    I'd like to work with this.
    So, as long as I enter any stock abbreviation/symbol (available on this site) in cell A3 and hit refresh, the data will populate into cells D1 through O13.
    However, when I enter a stock abbreviation in A3 and select "Refresh All" (under the DATA tab), I get a message that I don't understand.
    I have uploaded a PDF of the screenshot.
    What am I doing wrong?
    Thank you
    Doofus.
    Attached Files Attached Files
    Last edited by Doofus1; 10-26-2020 at 03:26 PM.

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

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Don't know why. It obviously works for me. Suggest you try and rebuild it yourself using my Mcode as a guide. It may have to do with the connection table not passing with the file. You have all the pieces to make it work. You just need to replicate it all in a new file.

  9. #9
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    I am now on an old computer that is running Excel 2010.
    At work it is the most recent version of Excel.
    I downloaded the document at work and tried but failed.
    What am I missing?
    I go to the POWERQUERY tab, FROM OTHER SOURCES > BLANK QUERY > ADVANCED EDITOR > copy and paste both your codes in the advanced editor

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

    And I get a message that reads:

    Expression.SyntaxError: Token Eof expected.

    What am I dealing with ?

    Please note that I am not very Powerquery savvy.
    Thank you
    Doofus
    Last edited by Doofus1; 10-24-2020 at 03:49 AM.

  10. #10
    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,410

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Doofus - please add code tags to your post as per the forum rules. Thanks.

    No further help to be offered until this is done.
    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.

  11. #11
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi AliGW,
    Ok. I am dumb.
    I go to edit post and select # tags before and after areas containing the code, but I don't see a difference in appearance after I post a quick reply.
    Duh! I feel really dumb.
    Thank you
    Doofus.
    Last edited by Doofus1; 10-24-2020 at 03:39 AM.

  12. #12
    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,410

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    1. Select the text that is code.
    2. With the text selected, click the # icon on the toolbar.

  13. #13
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    HAHAHAHA!!
    Thank you!!

  14. #14
    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,410

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Perfect!

    Can you attach a file that displays the syntax error you refer to? It usually means there's a comma missing at the end of a line.

  15. #15
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi AliGW,
    Attached is an Excel 2010 file with the code that does not appear to work.
    Thank you
    Doofus

    be back in about 8 hrs
    Attached Files Attached Files

  16. #16
    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,410

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    The code given by Alan is for two queries, as per the sample sheet he attached. You have tried to put them together into one query, hence the problem.

    I won't be here in 8 hours - I'll be offline by then.

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

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Here is step by step instructions attached. I am using Excel 2019, so the pictures may look a little different but you should be able to handle it.

    Suggest if you are going to play in the PQ arena, you get a copy of "M is for (Data) Monkey" by Ken Puls and Miguel Escobar. It is an excellent primer to learn PQ.
    Attached Files Attached Files

  18. #18
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    Tried doing this but I still cannot create the connection.
    Could you take a look at my Excel file and tell/show me what I am doing wrong?
    Thank you
    Doofus
    Attached Files Attached Files

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

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    I replaced your first line of Mcode with mine. I suspect it was a spacing within the URL. It works for me now.
    Attached Files Attached Files

  20. #20
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    I apologize for harassing you.
    However, it does not work when I type in a stock abbreviation in cell A2 and go to the DATA tab and select REFRESH ALL.
    I get a message that reads
    Query 'Table 0'(step 'AutoRemovedColumns1') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.
    The internet connection is fine.
    Any suggestions?
    Thank you
    Doofus

  21. #21
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    Could the issue come from the website address?
    The address https://finviz.com/quote.ashx?t=AAON&ty=c&ta=0&p=m&b=1 is for a monthly / 5year chart
    The address https://finviz.com/quote.ashx?t=aaon is probably the daily chart.
    Thus, would using the second web address be a better fit for getting the data to populate into the relevant cells once a stock ticker symbol is entered in cell A2?
    But my immediate problem is that since we are only using the data in Table 0, I still cannot figure out how to enter the stock ticker symbol in cell A2 to get the Table 0 data to automatically populate into cells D1 through O13.
    I have uploaded another Excel 10 spreadsheet with the initial data entered onto it.
    If you (I know I've tried your patience) or anyone else is willing to look at this again, I'd appreciate it.
    Thank you
    Doofus
    Attached Files Attached Files
    Last edited by Doofus1; 10-24-2020 at 09:27 PM.

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

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    I really don't understand your issue. Everything works for me. Perhaps it is time for you to learn PQ from the start figure this out. Everything you have given me works for me so I don't understand what you need. There is nothing more I can offer you.

  23. #23
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,039

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    I believe the issue is with the Excel version. It's not working for my Excel 2016 as well.

  24. #24
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    No worries. Thank you for showing me that it is possible.
    I'd like to keep this thread open a little longer in case there is anyone else out there with a better way to do this.
    Thank you all
    Doofus

  25. #25
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Folks,
    On the Excel sheet uploaded, under Powerquery - Advanced Editor, I get the message
    Formula.Firewall: Query 'Table 0' (step 'Changed Type') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.
    Could anyone download the Excel sheet and test to see if (1). The spreadsheet works and (2) if it does not, check to see if it produces that message and if so, outline a solution if one exists?
    Thank you
    Doofus
    Attached Files Attached Files

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

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    @Doofus1

    I downloaded and ran it with different Ticker Symbols. Works perfectly for me. No errors. No issues.

  27. #27
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    When I enter a ticker symbol into cell A2 and select the DATA tab, and select REFRESH ALL, I get the same message and when I click on the ACCESSIBILITY INVESTIGATE message on the bottom, I get the second screen.
    Do you or anyone else have any thoughts or ideas as to why this is occurring?
    Thank you
    Doofus
    Attached Files Attached Files

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

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Thoughts and not necessarily solutions

    1. Your versions of Excel/Power Query are corrupted? Maybe reinstall/run repairs?
    2. Older versions of PQ are not compatible with later versions? Not aware if this is true, however.

    This is the best I can offer as it does work with my version of Excel and PQ.

  29. #29
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    Could you look at this webpage https://social.technet.microsoft.com...-a-data-source and tell me if the final post contains a possible solution and if so, show me how to write the code so that it loads correctly?
    Thank you
    Doofus

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

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    I have done a little bit of research and wonder if it is your privacy settings. Read excerpt below that I pulled from another site

    This error happens because you are trying to access data from two different Datasets . I was able to fix this issue by setting Privacy Levels under File > Options and Settings > Options > Privacy.


    Once there, set the settings to "Always Ignore Privacy Level Settings"
    Attached Images Attached Images

  31. #31
    Forum Contributor
    Join Date
    06-04-2014
    Location
    Nevada, USA
    MS-Off Ver
    2010, 2013
    Posts
    342

    Re: Using Powerquery to import data from a website to an Excel spreadsheet.

    Hi Alansidman,
    YES!!!!
    That is the trick!!!!
    I apologize for being a pest but I probably have a compulsive disorder too.
    Thank you!! Thank you!!! THANK YOU!!!!
    Best
    Doofus.
    Last edited by Doofus1; 10-27-2020 at 01:40 AM.

+ 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. Use VBA to import CSV file to PowerQuery Data Model
    By varundutta10 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2019, 09:01 AM
  2. Replies: 0
    Last Post: 04-29-2019, 11:00 AM
  3. [SOLVED] How to Import data from multiple pages of a website into a single Excel sheet
    By JigneshBavishi in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-06-2016, 11:55 PM
  4. import data from a website into excel 2003
    By za4 in forum Hello..Introduce yourself
    Replies: 4
    Last Post: 07-31-2013, 01:21 AM
  5. Trying to import data from website to Excel
    By stronz in forum Excel General
    Replies: 1
    Last Post: 01-13-2011, 11:27 PM
  6. import excel data to website
    By robster52 in forum Excel General
    Replies: 0
    Last Post: 05-24-2010, 05:30 PM
  7. Need to import data from website to Excel file
    By sebastianpreda in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-02-2010, 02:15 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