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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I am attempting to have a function call an API request for each day of the year. I want to achieve this by having the function "Query2" make a call for each day which is provided by a pre-generated list.
Query2 Function:
(dayDate as date) as table =>
let
Source = Xml.Tables(Web.Contents("https://API.EXAMPLE.com/api/stats/groups/104/interactions?d=" & Date.ToText(#date(dayDate)))),
Table0 = Source{0}[Table],
#"Changed Type" = Table.TransformColumnTypes(Table0,{{"media-type", type text}, {"origination", type text}, {"create-timestamp", type datetimezone}, {"wrap-up-code", type text}, {"wrap-up-text", type text}, {"is-interaction-completed", type logical}})
in
#"Changed Type"The table with generated dates is:
let
DateRange= List.Dates(#date(2019,01,01),365,#duration(1,0,0,0)),
Source = List.Transform(DateRange, each try {(_), Query2(_)} otherwise null),
First = List.FirstN(Source, each _ <> null),
Table = Table.FromRows(First, {"date", "Column1"}),
#"Changed Type" = Table.TransformColumnTypes(Table,{{"date", type date}})
in
#"Changed Type"I am receiving one of two errors. The first comes with the above code:
An error occurred in the ‘’ query. Expression.Error: 1 arguments were passed to a function which expects 3.
Details:
Pattern=
Arguments=ListWhen the call for "Query2" is adjusted to "Query2(_,"","") I recieve the following error:
Expression.Error: 3 arguments were passed to a function which expects 1.
Details:
Pattern=
Arguments=ListSo I am assuming I have at least two functions that have different expected number of arguments but do not know how to resolve this.
Thanks.
Solved! Go to Solution.
@Anonymous
#date function needs 3 paramaters.
Perhaps adjust the function as follows
(dayDate as date) as table =>
let
Source = Xml.Tables(Web.Contents("https://API.EXAMPLE.com/api/stats/groups/104/interactions?d=" &
Date.ToText(#date(Date.Year(dayDate),Date.Month(dayDate),Date.Day(dayDate))))),
Table0 = Source{0}[Table],
#"Changed Type" = Table.TransformColumnTypes(Table0,{{"media-type", type text}, {"origination", type text}, {"create-timestamp", type datetimezone}, {"wrap-up-code", type text}, {"wrap-up-text", type text},
{"is-interaction-completed", type logical}})
in
#"Changed Type"
@Anonymous
#date function needs 3 paramaters.
Perhaps adjust the function as follows
(dayDate as date) as table =>
let
Source = Xml.Tables(Web.Contents("https://API.EXAMPLE.com/api/stats/groups/104/interactions?d=" &
Date.ToText(#date(Date.Year(dayDate),Date.Month(dayDate),Date.Day(dayDate))))),
Table0 = Source{0}[Table],
#"Changed Type" = Table.TransformColumnTypes(Table0,{{"media-type", type text}, {"origination", type text}, {"create-timestamp", type datetimezone}, {"wrap-up-code", type text}, {"wrap-up-text", type text},
{"is-interaction-completed", type logical}})
in
#"Changed Type"
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |