2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[PowerApps]ユーザー定義関数(UDF)が使用できるようになった

Posted at

背景

PowerAppsで関数(PowerFx)を実装しているとき、共通関数を作成したくなります。そこで、2025年入ってからユーザー定義関数を定義できるといううれしいお知らせがあったので、手順を記事に残しておきます。

設定

Power Apps Studioで、設定>更新>試験段階>ユーザー定義関数をONにします。
image.png

関数定義実装

Apps>Formulasで関数を定義する。

$定義関数名$(引数変数:引数型):戻り値型 = {$処理$;};
IsWeekEnd(d:Date):Boolean = {If(Weekday(d) = 7 || Weekday(d) = 1, true, false);};

日付を渡し、土曜または日曜か判定した結果を返す関数を共通関数として定義する。
image.png

関数定義を使った処理実装例

ボタンコントロール>OnSelectに上記で定義した関数を実装してみました。

If(IsWeekEnd(DatePicker1.SelectedDate),Notify("土日です。"),Notify("平日です。"));

動作確認-平日

image.png

動作確認-土日

image.png

プラスα

戻り値なし関数

:Voidをつけます。
image.png

複数関数をユーザー定義関数に組み込み

ユーザー定義した関数別のユーザー定義関数の処理に組み込むことも可能です。
image.png

まとめ

Saas系のサービスは特に変化が速いため、日々アップデート情報をチェックしていきたいと考えております。
便利な機能が出てきたら、普段の開発に取り込んでいきたいと考えております。
この記事が皆さんの役に立てば幸いです!
疑問点何かありましたら、コメントいただけると幸いです。
記事をご覧いただきありがとうございます。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?