1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Power Apps】Blank関数、Coalesce関数、IsBlank関数、IsEmpty関数とは、使い方

Posted at

Blank関数、Coalesce関数、IsBlank関数、IsEmpty関数について概要と活用例を紹介します。

紹介する内容

  • Blank関数とIsBlank関数の空白判定の差異
  • IsEmpty関数とIsBlank関数の違い
  • Coalesce関数の活用方法

似たような名前ですが、それぞれ使い方が異なるので説明します。


関数説明・構文 (一部Learnより引用)

Blank関数

nullと同じ値を出力する引数なし関数です。
""(空白の文字列)とは異なります。

空白 の値を返します。データ ソースに NULL 値を挿入するために使用できます。
公式より引用

Blank()

Coalesce関数

引数に入力した値の中で最初に空白ではない値を出力します。
If(IsBlank(), ~) のような処理を短縮できます。

空白 以外の値は変更せずに、空白 の値を置き換えます。
公式より引用

Coalesce(値1 [, 値2, ... ] )

IsBlank関数

レコードや値の空白判定をする関数です。

blank の値がないかを調べます。
公式より引用

IsBlank(値)

IsEmpty関数

テーブルの空白判定をする関数です。

空のテーブルがないかを調べます。
公式より引用

IsEmpty(テーブル)

使い方

Blank関数とIsBlank関数の空白判定の差異

  • Blank関数null 値を扱うため、""(空白文字列)とは異なります。結果は false になります。
  • IsBlank関数"" でも Blank() でも true になります。

image.png
image.png
image.png


IsEmpty関数とIsBlank関数の違い

  • IsEmpty関数 はテーブルの空白判定をします。
  • IsBlank関数 はレコードまたは値の空白判定をします。

空白のテーブルでは IsEmptytrue になり、IsBlankfalse になります。
空白の値やレコードでは IsEmpty はエラーになります。

image.png


Coalesce関数の活用方法

最初に空白ではない値を出力します。
IsBlank 同様に "" も空白として処理されます。

image.png

LookUp関数の結果が存在する場合のみ結果を表示

存在しない場合は "該当なし" を表示する例です。

If(
    IsBlank(LookUp(SampleList, タイトル = "iPhone 16", タイトル)),
    "該当なし", 
    LookUp(SampleList, タイトル = "iPhone 16", タイトル)
)

Coalesce(LookUp(SampleList, タイトル = "iPhone 16", タイトル), "該当なし")

image.png
image.png

条件分岐で行の追加/更新を行う場合

型の異なる値や動作の関数を並列で入力できないため、If を使用します。

If(
    IsBlank(LookUp(SampleList, タイトル = "iPhone 16", タイトル)), 
    Collect(SampleList, {タイトル:"iPhone 16"}),
    UpdateIf(SampleList, タイトル = "iPhone 16", {タイトル:"iPhone 16"})
)

image.png


まとめ

  • Blank関数null 値を出力
  • IsBlank関数:値やレコードの空白を判定
  • IsEmpty関数:テーブルの空白を判定
  • Coalesce関数:最初に空白ではない値を出力

用途に応じて関数を使い分けることで、効率的な条件分岐やデータ処理が可能になります。

元記事

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?