cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bstock Frequent Visitor
Frequent 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 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!

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisMendoza Senior Member
Senior Member

Re: Token Comma Expected in Custom Function - Can't figure out where it's missing...

@bstock -

You didn't close maybe?

Source = Csv.Document(Web.Contents(RequestURL),

as

Source = Csv.Document(Web.Contents(RequestURL)),

 

View solution in original post

2 REPLIES 2
ChrisMendoza Senior Member
Senior Member

Re: Token Comma Expected in Custom Function - Can't figure out where it's missing...

@bstock -

You didn't close maybe?

Source = Csv.Document(Web.Contents(RequestURL),

as

Source = Csv.Document(Web.Contents(RequestURL)),

 

View solution in original post

bstock Frequent Visitor
Frequent Visitor

Re: Token Comma Expected in Custom Function - Can't figure out where it's missing...

#facepalm

 

Thanks.  Seems the longer I stare at something the harder it is to find those things. 

 

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 154 members 1,870 guests
Please welcome our newest community members: