Forum

Notifications
Clear all

Date Problem

8 Posts
3 Users
0 Reactions
145 Views
(@cmckeever)
Posts: 38
Trusted Member
Topic starter
 

Hi,

I like to download horse racing information and see if I can pick winners. (No luck so far, lol.)  The information is in tables (8 to 14 races, thus 8 – 14 tables per race track).  The URL for one of the tracks is:

https://entries.horseracingnation.com/entries-results/parx-racing/2019-03-25

As you can see it has a date in it, so each day I must change the date in the query.  It becomes tedious if you do more than one track.  I checked the web and found that there are functions for extracting the year, month and day (Date.Year – Date.Month – Date.Day).  I tried to substitute the functions for the date, but since I am a novice at Power Query, I was unsuccessful.

Being naturally lazy, I was wondering if there is any way I can substitute the functions for the dates.  Any help would be appreciated.

TIA,

Cedric McKeever

 
Posted : 02/04/2019 9:02 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Cedric,

Power Query session 7.02 deals with this scenario.

Mynda

 
Posted : 02/04/2019 6:02 pm
(@cmckeever)
Posts: 38
Trusted Member
Topic starter
 

Wow, that looks complicated.  I am going to have to review that a couple of times to figure that out.

Thanks for the quick reply.

Cedric McKeever

 
Posted : 02/04/2019 8:32 pm
(@cmckeever)
Posts: 38
Trusted Member
Topic starter
 

let
#"Race 1" = (varDate as text) =>
let
Source = Web.Page(Web.Contents("https://entries.horseracingnation.com/entries-results/gulfstream-park/"&varDate&"")),
Data0 = Source{0}[Data],

 

I have to admit that I am not the brightest bulb in the room, but after going over lesson 7.2 several times I finally got the download to work, sort of.  I only get the first of eight tables.  So, I am assuming that I need a second variable for the rest of the tables.  I guess it should go in the line above:

data0 = Source{0}[Data]

the 0 is where the variable should go.  It is the table number.

So, I have two questions:

1)  Do I need a second variable?

2)  How do I enter the second variable?  I have tried several things but none of them worked.  If a second variable is the solution, would you point me to a lesson on how to enter numerous variables.

TIA,

Cedric McKeever

 
Posted : 05/04/2019 10:05 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi Cedric,

Have you tried:

let
#"Race 1" = (varDate as text, Position) =>
let
Source = Web.Page(Web.Contents("https://entries.horseracingnation.com/entries-results/gulfstream-park/"&varDate&"")),
Data0 = Source{Position}[Data],

Pass 0 to Position argument to get the first entry, 1 for second, and so on.

 
Posted : 05/04/2019 11:28 pm
(@cmckeever)
Posts: 38
Trusted Member
Topic starter
 

Catalin,

Thank you for taking time to answer.

No I have not tried that.  Being a novice I had no idea how to enter a second variable.

Do you have to initialize "Position" as text, or is it understood?

Sorry to ask so many questions.

Cedric McKeever

 
Posted : 06/04/2019 7:52 am
(@catalinb)
Posts: 1937
Member Admin
 

If type is not specified, it will be considered as type any.

You can specify a type if you want, but it should not be text, as the position is an integer in {Position}.

 
Posted : 06/04/2019 1:28 pm
(@cmckeever)
Posts: 38
Trusted Member
Topic starter
 

Hi, Mynda and Catalin,

IT WORKS!!!!!!!

You guys are geniuses. Thanks.

Cedric McKeever

 
Posted : 06/04/2019 8:41 pm
Share: