Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
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 Source
But 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!
Solved! Go to Solution.
@bstock -
You didn't close maybe?
Source = Csv.Document(Web.Contents(RequestURL),
as
Source = Csv.Document(Web.Contents(RequestURL)),
Proud to be a Super User!
@bstock -
You didn't close maybe?
Source = Csv.Document(Web.Contents(RequestURL),
as
Source = Csv.Document(Web.Contents(RequestURL)),
Proud to be a Super User!
#facepalm
Thanks. Seems the longer I stare at something the harder it is to find those things.