有办法逃避M中的逗号吗?尝试通过 Power B 中的高级编辑器传递此字符串:“MA”,“OH”。但它因逗号而中断 [关闭]

问题描述 投票:0回答:1

When I try to pass variables in the advance editor, I cant seem to escape the comma.

我试图通过在逗号前后放置双引号 (") 来转义字符串中的逗号,但它也没有用。 这是 M 中的 let 函数,用于调用 API 并传递变量值。问题是对于状态字段,它不允许我使用逗号并导致脚本中断。有什么好的逃生方法吗?

() =>
let
  url = api_url,
  authorization ="Bearer " & api_key,

  variables_values = Text.Format(
    """variables"": {
      ""state"": ""["""MA"""," ""ME""]"",
      ""property_use_code_mapped"": ""44""
    }",
    [

    ]
  ),
  request_body = Text.Format("{""query"":
    ""query taxassessorQuery($state: [String!], $property_use_code_mapped:[bigquery_decimal!]) {
      tax_assessor(
        limit: #[records_per_page]
        where: {
          property_use_code_mapped: {_in: $property_use_code_mapped}
          state: {_in: $state}
        } order_by:{tax_assessor_id:asc}) 
    {
    tax_assessor_id
    address
    city
    state
    zip
    latitude
    longitude
    year_built
    }
    }"",
    #[variables_values]
  }",
  [
    records_per_page = 10,
    variables_values = #"variables_values"
  ]
  ),
  request_cleaned = Text.Clean(request_body),
  request_encoded_as_binary = Text.ToBinary(request_cleaned),
  json_response = Json.Document(Web.Contents(url,[
    Headers = [#"Authorization"=authorization,#"Content-Type"="application/json"],
    Content = request_encoded_as_binary
  ] )),
  data = json_response[data]
in
  data
variables powerbi powerquery m let
1个回答
0
投票

你想得到这个输出吗?

“变量”:{ “状态”:“[“MA”,“ME”]”, “property_use_code_mapped”:“44”}

使用

let variables_values = 
  """variables"": {
   ""state"": ""[""MA"",""ME""]"",
   ""property_use_code_mapped"": ""44""}",
© www.soinside.com 2019 - 2024. All rights reserved.