Forum Discussion

d215aquitania's avatar
d215aquitania
Frequent Visitor
6 years ago
Solved

Expression.Error: 3 arguments were passed to a function which expects between 1 and 2. - help please

I'm getting this error which is driving me nuts that I'm hoping somebody can spot just what I'm doing wrong.  I'm sure it must be something to do with the dates I'm using, but what?  Everything I've tried keeps coming back to the same problem.  

 

Here's the function that is being called: 

 

let
Source2 = (MyStartDate as date, MyEndDate as date, MyTimeUnit as text, MyAPIKey as text) as table =>
let
Source = Json.Document(Web.Contents("https://monitoringapi.solaredge.com",
[
RelativePath="site/123456/energy"
],
[
Query= "startDate=" & Date.ToText(MyStartDate, "yyyy-mm-dd")
& "&endDate=" & Date.ToText(MyEndDate, "yyyy-mm-dd")
& "&timeUnit=" & MyTimeUnit
& "&api_key=" & MyAPIKey
]
)
),
#"Converted to Table" = Record.ToTable(Source),
#"Expanded Value" = Table.ExpandRecordColumn(#"Converted to Table", "Value", {"timeUnit", "unit", "measuredBy", "values"}, {"timeUnit", "unit", "measuredBy", "values"}),
#"Expanded values" = Table.ExpandListColumn(#"Expanded Value", "values"),
#"Expanded values1" = Table.ExpandRecordColumn(#"Expanded values", "values", {"date", "value"}, {"date", "value"})
in
#"Expanded values1"
in
Source2

 

And here is the call: 

 

let
Source = URL,
#"Invoked Custom Function" = Table.AddColumn(Source, "Usage", each Usage([StartDate], [EndDate], [TimeUnit], [api_key]))
in
#"Invoked Custom Function"

 

Timeunit is just some text ("quarter-of-an-hour") and the api_key just text.  StartDate & EndDate are dates.  

 

Can anybody spot anything that I might change here?  

 

Thanks in advance.  

4 Replies

    • d215aquitania's avatar
      d215aquitania
      Frequent Visitor

      Thanks for looking.  This is all I'm getting by way of an error:

       

      Expression.Error: 3 arguments were passed to a function which expects between 1 and 2.
      Details:
      Pattern=
      Arguments=[List]

       

      I'm not able to pin it down any closer than that.  If I invoke the function directly & input the relevant values, I still get the same.  

  • Hi, you have an error in web.content. It should be like this:

    Web.Contents("https://monitoringapi.solaredge.com",
    [
        RelativePath="site/123456/energy",
        Query= [
            startDate=Date.ToText(MyStartDate, "yyyy-mm-dd"),
            endDate=Date.ToText(MyEndDate, "yyyy-mm-dd"),
            timeUnit=MyTimeUnit,
            api_key=MyAPIKey
        ]
    ]
    )

    You can check sintaxis here in case I have something wrong: https://blog.crossjoin.co.uk/2016/08/16/using-the-relativepath-and-query-options-with-web-contents-in-power-query-and-power-bi-m-code/

    Hope that helps,