• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

can you use an if then when trying to download elements rather than a table?|Power Query|Excel Forum|My Online Training Hub

You are here: Home / can you use an if then when trying to download elements rather than a table?|Power Query|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower Querycan you use an if then when trying …
sp_PrintTopic sp_TopicIcon
can you use an if then when trying to download elements rather than a table?
Avatar
doug marcus

New Member
Members
Level 0
Forum Posts: 1
Member Since:
April 7, 2023
sp_UserOfflineSmall Offline
1
April 7, 2023 - 5:42 am
sp_Permalink sp_Print

This is my first question to the group so be kind.

I have developed a power query to Yahoo Finance that extracts every table from the summary & statistics pages and places it into one table. really slick use of that turning a web query into a function and the function reads the input from each address in the table. the issue is that when i come to the financial pages, they are only html documents. so i created same function but i used the xpath addresses. it works but .... one of the companies is behind in its reporting. thus each company has the same number of rows ... cash, equity, revenue. but this one has less columns because it is behind two quarters.

https://finance.yahoo.com/quot.....?p=MPXOF  1-quarterly column and 1 trailing 12 month column

https://finance.yahoo.com/quot.....s?p=EOSE      4-quarterly columns and 1 trailing 12 month column

 

thus, when i compare the xpath, i get this difference

  EOSE MPXOF
TRUE html[1] html[1]
TRUE body[1] body[1]
TRUE div[1] div[1]
TRUE div[1] div[1]
TRUE div[1] div[1]
TRUE div[1] div[1]
TRUE div[1] div[1]
TRUE div[3] div[3]
TRUE div[1] div[1]
TRUE div[1] div[1]
TRUE div[2] div[2]
FALSE div[1]  
FALSE div[1]  
TRUE section[1] section[1]
TRUE div[3] div[3]
TRUE div[1] div[1]
TRUE div[1] div[1]
TRUE div[1] div[1]
TRUE div[1] div[1]
TRUE div[2] div[2]
TRUE span[1] span[1]

thus, a query using the 5 columned table for MPXOF comes back with an error and the query only keeps everything up to MPXOF. There are only two levels separating the two so can you say in the function if no error use xpath1 and there is an error use xpath2?

 

thanks;

Doug Marcus

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1824
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
April 8, 2023 - 8:03 pm
sp_Permalink sp_Print

Hi Doug,

You can try:

try Function(xpath1) otherwise Function(xpath2)

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Alain Balken
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 216
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Melanie Ford
Isaac Felbah
Adele Glover
Hitesh Asrani
Rohan Abraham
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Forum Stats:
Groups: 3
Forums: 24
Topics: 6356
Posts: 27793

 

Member Stats:
Guest Posters: 49
Members: 32324
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.