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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.