Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Power Automate の新関数について

Avatar for MiyakeMito MiyakeMito
December 03, 2022

Power Automate の新関数について

Avatar for MiyakeMito

MiyakeMito

December 03, 2022
Tweet

More Decks by MiyakeMito

Other Decks in Technology

Transcript

  1. 本日の参考サイト 5 ◼ Azure Logic Apps および Power Automate のワークフロー式関数のリファレン

    ス ガイド hhttps://learn.microsoft.com/ja-jp/azure/logic-apps/workflow-definition- language-functions-reference ◼ Power Automate 2022年9月に追加された強力な新関数の紹介 https://qiita.com/MiyakeMito/items/b25be62405c04aca2e9c
  2. きょうの関数 8 ➢ sort 配列内の項目を並べ替えます ➢ reverse 配列内の項目の順序を逆にします ➢ chunk

    文字列または配列を等しい長さのチャンクに分割します ➢ isInt 文字列が整数かどうかを示すブール値を返します ➢ isFloat 文字列が浮動小数点数かどうかを示すブール値を返します ➢ dateDifference 2 つの日付の差をタイムスパンとして返します
  3. sort([<collection>], <sortBy>?) 10 ◼ 配列の構造を持つ、コレクション内のアイテムを昇順(asc)に並べ替え ることができます。 ◼ ソートの対象は Array である必要があります。

    ◼ 降順(desc)に並べる場合は、後述の reverse() 関数と組み合わせます。 [ "パンダ", "ライオン", "ペンギンロボ" ] [ "パンダ", "ペンギンロボ", "ライオン" ] [ 3, 1, 2 ] [ 1, 2, 3 ] sort(Array) sort(Array)
  4. sort([<collection>], <sortBy>?) 11 ◼ ソートキーとしてカラムを指定可能です。 [ {"col1":"1","col2":35}, {"col1":"2","col2":22}, {"col1":"3","col2":10} ]

    [ {"col1":"3","col2":10} {"col1":"2","col2":22}, {"col1":"1","col2":35}, ] sort(Array, 'col2') ◼ 複数のソートキーを指定不可。よっては工夫が必要です。 [ {"col1":"1","col2":3,"col3":2}, {"col1":"2","col2":3,"col3":1}, {"col1":"3","col2":2,"col3":2} ] [ {"col1":"3","col2":2,"col3":2 ,"col4":"22"}, {"col1":"2","col2":3,"col3":1 ,"col4":"31"}, {"col1":"1","col2":3,"col3":2 ,"col4":"32"} ] [ {"col1":"1","col2":3,"col3":2 ,"col4":"32"}, {"col1":"2","col2":3,"col3":1 ,"col4":"31"}, {"col1":"3","col2":2,"col3":2 ,"col4":"22"} ] sort(Array, 'col4')
  5. reverse([<collection>]) 13 ◼ コレクション内の項目の順序を逆にします。 ◼ sort() と組み合わせると、コレクションを降順(desc)にソートできます。 [ "パンダ", "ライオン",

    "ペンギンロボ" ] [ "ライオン", "ペンギンロボ", "パンダ" ] [ 3, 1, 2 ] [ 2, 1, 3 ] reverse(Array) reverse(sort(Array)) [ 3, 1, 2 ] [ 3, 2, 1 ] reverse(sort(Array))
  6. chunk('<collection>', '<length>') 17 ➢ 要素がオブジェクトの構造を持つ配列のチャンクも同様の動きです。 chunk( Array, 4 ) [

    {"col1":"1","col2":35}, {"col1":"2","col2":22}, {"col1":"3","col2":33}, {"col1":"4","col2":84}, {"col1":"5","col2":21}, {"col1":"6","col2":95}, {"col1":"7","col2":35}, {"col1":"8","col2":96}, {"col1":"9","col2":24}, {"col1":"10","col2":1} ] [ [ {"col1":"1","col2":35}, {"col1":"2","col2":22}, {"col1":"3","col2":33}, {"col1":"4","col2":84} ], [ {"col1":"5","col2":21}, {"col1":"6","col2":95}, {"col1":"7","col2":35}, {"col1":"8","col2":96} ], [ {"col1":"9","col2":24}, {"col1":"10","col2":1} ] ]
  7. 21 isFloat('<string>', '<locale>'?) ◼ 文字列が浮動小数点数であるかどうかを示すブール値を返します。 第1引数は文字列型である必要があります。 isFloat('10.000,00', 'de-DE') true isFloat('-1.7976931348623e+308')

    true ➢ ロケール固有の形式で表される浮動小数点数を識別するには、オプションで第2引数に RFC4646ロケール・コード を指定します。 (既定ではインバリアント カルチャが適用される) isFloat('123') true
  8. dateDifference('<startDate>', '<endDate>') 23 ◼ endDateからstartDateを減算し、結果を文字列形式でタイムスタンプと して返します。 ◼ 日付の形式は、ISO 8601 に準拠していれば、正常に動作します。

    dateDifference('2022-09-28', '2022-09-23') "-5.00:00:00" dateDifference('2022-12-03T20:20:30.000', '2022-12-25T00:00:00.000') "21.03:39:30" ➢ 時間の計算も可能な模様(リファレンスに記載が無いので注意)