12
1

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 で日付の選択コントロールでフィルターする際上手くデータが表示されない

Last updated at Posted at 2024-12-16

はじめに

以下のようなトレーニングの日程を管理しているリストを作成しています。そして、ユーザーが Power Apps で申し込み可能なトレーニングを探したいとします。

image.png

この場合、以下のような感じで、期間、ステータスでフィルターするアプローチがあります。
しかし、以下の場合、8/30 に申し込み可能なトレーニングがあるにもかかわらず、上手く見つかりません。

image.png

Filter(
    Training,
    StartTime >= dteStart.SelectedDate && EndTime <= dteEnd.SelectedDate && TrainingStatus.Value = "申し込み可"
)

今回は、原因と対策について備忘のため整理しておきます。

原因

モニターツールで原因を調査してみます。

image.png

image.png

ポイントは以下の部分です。実際には以下のようなリクエストを SharePoint に送っています。これを見ると、UTC の"2024-08-29T15:00:00.000Z"、つまり、日本時間の開始時間と終了時間が 8/30 0:00 から 8/30 0:00 のトレーニングを検索していることになります。

$filter=((StartTime ge datetime'2024-08-29T15:00:00.000Z')and(EndTime le datetime'2024-08-29T15:00:00.000Z'))and(TrainingStatus eq '申し込み可')

対策

対策としては、終了時間の方の日付の選択コントロールの時間について、その日の最終時間、例えば、23:59:59、または翌日の 0:00:00 にしてあげる方法があります。以下、式のイメージです。

Filter(
    Training,
    StartTime >= dteStart.SelectedDate && EndTime <= DateTimeValue(
        Text(
            dteEnd.SelectedDate,
            "yyyy-mm-dd"
        ) & " 23:59:59"
    ) && TrainingStatus.Value = "申し込み可"
)
Filter(
    Training,
    StartTime >= dteStart.SelectedDate && EndTime <= DateAdd(dteEnd.SelectedDate,1,TimeUnit.Days)
       &&  TrainingStatus.Value = "申し込み可"
)

上手くトレーニングが表示されるようになりました。

image.png

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?