Expression error аргументы 2 были переданы функции которая ожидает 1 excel

let
    Источник = Folder.Files("C:UsersДокументыbackupСклады"),
    #"Отфильтрованные скрытые файлы1" = Table.SelectRows(Источник, each [Attributes]?[Hidden]? <> true),
    #"Вызвать настраиваемую функцию1" = Table.AddColumn(#"Отфильтрованные скрытые файлы1", "Преобразовать файл из Склады", each #"Преобразовать файл из Склады"([Content])),
    #"Переименованные столбцы1" = Table.RenameColumns(#"Вызвать настраиваемую функцию1", {"Name", "Source.Name"}),
    #"Другие удаленные столбцы1" = Table.SelectColumns(#"Переименованные столбцы1", {"Source.Name", "Преобразовать файл из Склады"}),
    #"Столбец расширенной таблицы1" = Table.ExpandTableColumn(#"Другие удаленные столбцы1", "Преобразовать файл из Склады", Table.ColumnNames(#"Преобразовать файл из Склады"(#"Пример файла"))),
    #"Измененный тип" = Table.TransformColumnTypes(#"Столбец расширенной таблицы1",{{"Source.Name", type text}, {"Дата", type date}, {"ИД сделки", Int64.Type}, {"Num Group", Int64.Type}, {"Gr Name", type text}, {"Код клиента DWH", Int64.Type}, {"Spv State", type any}, {"Код клиента", type text}, {"Группа компаний", type text}, {"Наименование клиента", type text}, {"Дата регистрации договора", type date}, {"Вид бизн. клиента", type text}, {"Вид бизн. сделки", type text}, {"Вид бизн. Mix", type text}, {"Блок с карточки клиента", type text}, {"Код фил. клиента", Int64.Type}, {"Код фил. сделки", Int64.Type}, {"Код фил. Mix", Int64.Type}, {"Назначение гарантии", type any}, {"Номер договора кред. линии", type text}, {"Номер  договора", type text}, {"Дата начала  договора", type date}, {"Дата завершения  договора", type date}, {"Дата фактического погашения", type date}, {"Статус", type text}, {"Тип сделки", type text}, {"Буквенный код валюты договора", type text}, {"Тип валюты", type text}, {"Сумма договора в валюте договора", type number}, {"Сумма договора в рублях", type number}, {"Комиссия", type number}, {"Дата вынесения на просрочку", type date}, {"Кол-во дней просрочки", Int64.Type}, {"Дата вынесения % на просрочку", type date}, {"Кол-во дней просрочки %", Int64.Type}, {"Максимальная просрочка", Int64.Type}, {"Кол-во проср дней", type number}, {"Cliprosrday", Int64.Type}, {"Cliprosrgraday", type number}, {"Вид_обесп_(max)", Int64.Type}, {"Вид_обесп_(FS)", type text}, {"Код продукта", type text}, {"Наименование продукта", type text}, {"Код цели", Int64.Type}, {"Признак БЛТ", type any}, {"Признак втричной продажи РБ", type any}, {"Сегмент", type text}, {"Менеджер привлечения по сделке", type text}, {"ФИО Привлеченца (Агент)", type any}, {"Cliprosr", Int64.Type}, {"Priz", type text}, {"Признак МКО", Int64.Type}, {"НПС ОД", Int64.Type}, {"ОД в RUB", type number}, {"ОД в USD", type number}, {"ОД в ориг. валюте", type number}, {"НПС ПОД", Int64.Type}, {"ПОД в RUB", type number}, {"ПОД в USD", type number}, {"ПОД в ориг. валюте", type number}, {"НПС дисконт", Int64.Type}, {"Дисконт в RUB", type number}, {"Дисконт", type number}, {"Дисконт в ориг. валюте", type number}, {"НПС бонус", type any}, {"Бонус в RUB", Int64.Type}, {"Бонус в USD", Int64.Type}, {"Бонус в ориг. валюте", Int64.Type}, {"Итог в KZT", type number}, {"Итог в USD", type number}, {"Итог в ориг. валюте", type number}, {"Provisperiod", type any}, {"И/К", type any}, {"Провизии И", type any}, {"Провизии К", type any}, {"Резерв в RUB", type number}, {"Резерв в USD", type number}, {"Резерв в ориг. валюте", type number}, {"Фрагмент", type text}, {"Признак ЮЛ", type text}, {"ТФ", Int64.Type}})
in
    #"Измененный тип"

Я пытался создать автоматизированный инструмент vba для извлечения данных API, но продолжал получать ошибку ниже от Power Query…

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

Продолжал искать решение, но не мог найти правильную причину…

Вот мой код, как показано ниже

let

    Parameter = Excel.CurrentWorkbook(){[Name = "Parameter"]}[Content],

    URL= Parameter[Column1]{0},

    Source = Json.Document(Web.Page(Web.Contents(URL), [
        Headers =[#"Authorization" = "Basic ENCODE64PASSWORDS"]])),
    
    #"Converted to Table" = Record.ToTable(Source),
    Value = #"Converted to Table"{0}[Value],
    results = Value[results],


    #"Converted to Table1" = Table.FromList(results, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"path", "upsertable"}, {"path", "upsertable"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Column1", each ([upsertable] = true)),
    #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"path", Order.Ascending}})
in
    #"Sorted Rows"

Я не профессиональный кодер, но только начал интересоваться миром кодирования.
Этот код в основном просто смесь копирования и вставки по всему Интернету, ха-ха
Поэтому, пожалуйста, поймите, что я только новичок с маленьким шагом, и простите мое невежество, если это на самом деле простое дело … или если я действительно не очень хорошо понимаю ваш ответ …

user21070263, 26 января 2023 г., 07:13

1

63

1

I have been trying to build an automated vba tool to pull API data but kept having below error from Power Query…

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

Kept looking up the solution but could not really find the right reason…

Here is my code as below

let

    Parameter = Excel.CurrentWorkbook(){[Name="Parameter"]}[Content],

    URL= Parameter[Column1]{0},

    Source = Json.Document(Web.Page(Web.Contents(URL), [
        Headers =[#"Authorization"="Basic ENCODE64PASSWORDS"]])),
    
    #"Converted to Table" = Record.ToTable(Source),
    Value = #"Converted to Table"{0}[Value],
    results = Value[results],


    #"Converted to Table1" = Table.FromList(results, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"path", "upsertable"}, {"path", "upsertable"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Column1", each ([upsertable] = true)),
    #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"path", Order.Ascending}})
in
    #"Sorted Rows"

I am no professional coder but just started to feel interested in coding world.
This code is mostly just mixture of copy and paste all over the web haha
So please understand im only a beginner with a baby step and forgive my ignorance if this is actually a simple matter..or if I dont really understand your reply well..

  • Remove From My Forums
  • Вопрос

  • Hi everyone,

    Has anyone any experience with the «[Expressio<g class=»gr_ gr_87 gr-alert
    gr_gramm gr_inline_cards gr_disable_anim_appear Style replaceWithoutSep» data-gr-id=»87″ id=»87″>n.Erro</g>r] 2 arguments were passed to a function which expects 1″ error as my colleagues keep getting it but
    I don’t get it?

    Even one of my colleagues has the very same laptop as I have and he also gets
    the same issues. The other people have the smaller laptops and they do get it but I developed the power query using my laptop so I never got that error.

    Any help is very much appreciated.

    Regards

    <g class=»gr_ gr_472 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace» data-gr-id=»472″ id=»472″>Etem</g>

Ответы

  • Hi Etem. Can you share the M formula text of the query where you’re seeing this error? If you’re seeing the error only on some users’ machines, it’s likely due to differing versions of Power Query. The newer version of the function may support a two arguments,
    while the older version only accepts one argument.

    Ehren

    • Предложено в качестве ответа

      19 октября 2018 г. 17:05

    • Помечено в качестве ответа
      Imke FeldmannMVP
      3 ноября 2018 г. 7:22

Hi there fellow users of Power Bi,

I am trying to obtain some data using an API.

I have managed to get the authentication token and managed to obtain some data, but only the first 100 items.

So now I am trying to loop through all the «pages» using count and an offset.

However I get the following error:
2 arguments were passed to a function which expects 1.

The below is my code, hopefully you can help me out 

let
// Get authorization token
Kilde = Web.Contents("https://api.XXXXXXXXX.dk/oauth2/token",
[Headers=[#"Content-Type"="application/x-www-form-urlencoded"],
Content=Text.ToBinary(Uri.BuildQueryString([grant_type="password", client_id="XXXXXXXXXXXXXXXXX", client_secret="XXXXXXXXXXXXXX", email="xxxxxxx@yyyyyyyyy.com", password="XXXXXXXXXXXXX"]))]),
KildeTekst = Text.FromBinary(Kilde),
KildeSegmenter = Splitter.SplitTextByDelimiter("&")(KildeTekst),
KildeKvps = List.Transform( KildeSegmenter,
(value) => {
List.First((Splitter.SplitTextByDelimiter("=")(value))),
List.Last((Splitter.SplitTextByDelimiter("=")(value)))
}
),
KildeKvpTabel = Table.FromList(KildeSegmenter, Splitter.SplitTextByDelimiter("=")),
#"Filtrerede rækker" = Table.SelectColumns(Table.SelectRows(KildeKvpTabel, each [Column1] = "access_token"), {"Column2"}),
Token = Text.From(List.First(Table.SelectColumns(Table.SelectRows(KildeKvpTabel, each [Column1] = "access_token"), {"Column2"})[Column2])),


EntitiesPerPage = 100,
BaseUrl = "https://api.xxxxxxxxxxx.dk/v1/organizations/XXXX/vouchers",


GetJson = (Url) =>
let Options = [Headers =[#"Authorization"="Bearer " & Token]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData,1252)
in Json,


GetEntityCount = () =>
let Url = BaseUrl & "?count=10",
Options = [Headers =[#"Authorization"="Bearer " & Token]],
Json = Web.Contents(Url, Options),
#"Derp" = Json.Document(Json,1252),
Count = Record.Field(#"Derp"[meta],"count")
in Count,


GetPage = (Index) =>
let
Options = [Headers =[#"Authorization"="Bearer " & Token]],
Skip = "&offset=" & Text.From(Index * EntitiesPerPage),
Top = "?count=" & Text.From(EntitiesPerPage),
Url = BaseUrl & Top & Skip,
Json = GetJson(Url, Options),
Value = Json[#"value"]
in Value,


EntityCount = List.Max({ EntitiesPerPage, GetEntityCount() }),
PageCount = Number.RoundUp(EntityCount / EntitiesPerPage),
PageIndices = { 0 .. PageCount - 1 },
Pages = List.Transform(PageIndices, each GetPage(_)),
Entities = List.Union(Pages),
Table = Table.FromList(Entities, Splitter.SplitByNothing(), null, null, ExtraValues.Error)

in
Table

I am pretty sure it’s:

Pages = List.Transform(PageIndices, each GetPage(_)),

Which is causing the issue.

If I take a look at GetPage = (Index) => 

I noticed in Postman it’s returning me a data and meta tag:

Postman_odOsBHvjNX.png

I tried changing the folowing line

Value = Json[#"value"]

with

Value = Json[data][#"value"]

But sadly without luck.

I really hope someone can help me, since I am pulling my hair out over this issue :S

Feel free to add me on skype: Futurelinkhev or hev@futurelink.dk if needed be 

Best regards

Понравилась статья? Поделить с друзьями:
  • Export java to excel
  • Expression a sentence for each word
  • Export in pdf from word
  • Express your love in one word
  • Export in excel from sap