Power AutomateにはExcelでもお馴染みのRound, RoundDown/Up, Ceil/Floorなどの関数はありません。
でも比較的簡単に関数を組み合わせて作れるので、ご紹介します。
考え方
今回使うのは formatNumber関数 と int関数 または float関数です。
最終的に使う数式は以下のような形式です。
int(formatNumber(123.4567,'F0'))
※この結果は 123
float(formatNumber(123.4567,'F2'))
※3桁残すならこの結果は float(formatNumber(123.4567,'F3')) --> 123.457
最も重要な関数はformatNumberです。四捨五入自体はこの関数だけで完結していて float や int関数は後続処理で数値として扱いたい場合にのみ挿入してください。
関数解説
解説というほどでもありませんが。基本はformatNumber関数の使用例どおりです。
F0やF3は小数点以下0桁、3桁までは必ず残す、それ以下は丸めるというフォーマットです。
F0で小数点以下は0桁、つまり整数になるので、これを最後にint(...)
でくくれば整数になりますし、float(...)
でくくれば浮動小数点数が作られます。
※formatNumberだけだと、返す値は文字列です。
おわり
もう少し色々面倒な操作が必要かと思っていたらformatNumberが優秀でした。
Round、ceil、floorなどが Power Automate では用意されていないので、四捨五入したい場合にはこの組み合わせで使ってみて下さい。