Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
bstock
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
ChrisMendoza
Resident Rockstar
Resident Rockstar

@bstock -

You didn't close maybe?

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

as

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

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
ChrisMendoza
Resident Rockstar
Resident Rockstar

@bstock -

You didn't close maybe?

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

as

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

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



#facepalm

 

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

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors