Forum Discussion
bstock
7 years agoFrequent Visitor
Token Comma Expected in Custom Function - Can't figure out where it's missing...
Good day, this has been driving me up the wall for a few hours now, and goole isn't helping, so I have come to the experts :)
I have the following code in Power Query for a custom function I am working on:
let
//Define Input Parameters
Source = (Station as text, StartDate as date, EndDate as date) as table => let
//Define API Parameters
APIUrl = "https://mesonet.agron.iastate.edu/cgi-bin/request/asos.py?",
StartYear = "&year1=" & Number.ToText(Date.Year(StartDate)),
StartMonth = "&month1=" & Number.ToText(Date.Month(StartDate)),
StartDay = "&day1=" & Number.ToText(Date.Day(StartDate)),
EndYear = "&year2=" & Number.ToText(Date.Year(EndDate)),
EndMonth = "&month2=" & Number.ToText(Date.Month(EndDate)),
EndDay = "&day2=" & Number.ToText(Date.Day(EndDate)),
//Combine parameters for URL
RequestURL = APIUrl & "station=" & Station & "data=all&" & StartYear & StartMonth & StartDate & EndYear & EndMonth & EndDate & "&tz=Etc%2FUTC&format=onlycomma&latlon=no&missing=null&trace=T&direct=no&report_type=1&report_type=2",
//Retrieve Source Data
Source = Csv.Document(Web.Contents(RequestURL),
#"Promoted Headers1" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])
in #"Promoted Headers1"
in SourceBut it fails with the error " Token Comma Expected" I have bashed my head on this for a while, and I can't seem to sort out where i've gone wrong in my syntax. The error is flagged on the 1st "in" statement.
Thanks for any help in advance!
bstock -
You didn't close maybe?
Source = Csv.Document(Web.Contents(RequestURL),
as
Source = Csv.Document(Web.Contents(RequestURL)),
2 Replies
- ChrisMendoza
Resident Rockstar
bstock -
You didn't close maybe?
Source = Csv.Document(Web.Contents(RequestURL),
as
Source = Csv.Document(Web.Contents(RequestURL)),
- bstockFrequent Visitor
#facepalm
Thanks. Seems the longer I stare at something the harder it is to find those things.