演習 - Power Apps の MR で測定とフィルター処理
このユニットでは、Power Apps の主要な機能コンポーネントの一部を使用します。 これには、MR で測定とフィルター方法が含まれます。 ユーザーは、Power Apps の MR で測定コンポーネントを使用して、現実世界の距離、面積、体積を測定できます。
MR で測定を使用した空間フィルター
MR で測定機能は、測定セッションを通して受け取った測定値に従って現実世界に簡単に配置できるように、製品を空間的にフィルター処理するために使用されます。 このフィルター処理の実行には、いくつかの基本的な数式が使用されます。
Home page に移動します。 [挿入] タブで、[Mixed Reality] ドロップダウンを展開し、[MR 内のメジャー] を選択します。
図に示すように [MR で測定] ボタンを配置し、次のプロパティを構成します。
- テキスト: Filter by Dimensions
- 測定単位: Centimeters
- 測定の種類: Freeform
[ギャラリー]>[縦] を選択して Home page にギャラリーを追加します。 ギャラリーの名前を Measure_gallery に変更します。
[垂直ギャラリー] を [Filter by Dimensions] ボタンのすぐ下に配置します。 [タイトル、サブタイトル、本文] を選択して [レイアウト] プロパティを構成します。
次の行を追加して、Measure_gallery の Items プロパティを構成します。
MeasureInMR1.Measurements
Separator と NextArrow を削除します。 画像に示すように、タイトル、サブタイトル、本文を互いに等間隔に配置します。
3 つのラベルの Text プロパティを次のように構成します。
ユーザーが測定に不満足な場合に再実行できるように、[再読み込み] アイコンを追加しましょう。 [挿入] タブで、[アイコン] ドロップダウンを展開し、[再読み込み] アイコンを選択します。
次の図に示すようにアイコンを配置し、OnSelect プロパティを次のように構成します。
UpdateContext({galleryvisible:false});
ヒント
アプリケーションのデザインに合わせてフォント、フォント サイズ、フォント スタイルをカスタマイズできます。 ただし、ユーザー エクスペリエンス向上のために、アプリケーション全体で一貫したフォントを維持します。
MR で測定コンポーネントを完全に構成したら、空間フィルターに進みます。 ここでは、MR で測定セッションで受け取った Width、Depth、Height の値に基づいて、空間フィルターを適用します。
[製品] ページに移動した後、Gallery_products の Items プロパティを次のように構成します。
If( ID = 1 And Measure_gallery.Selected.Height = 0, (Filter('Easy Sales',(ProductCategory = "Sofa") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth)))), ID = 1 And Measure_gallery.Selected.Height > 0, (Filter('Easy Sales',(ProductCategory = "Sofa") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth And Height <= Measure_gallery.Selected.Height) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth And Height <= Measure_gallery.Selected.Height)))), ID = 1, Filter('Easy Sales',ProductCategory = "Sofa"), ID = 2, Filter('Easy Sales',ProductCategory = "Chair"), ID = 2 And Measure_gallery.Selected.Height = 0, (Filter('Easy Sales',(ProductCategory = "Chair") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth)))), ID = 2 And Measure_gallery.Selected.Height > 0, (Filter('Easy Sales',(ProductCategory = "Chair") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth And Height <= Measure_gallery.Selected.Height) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth And Height <= Measure_gallery.Selected.Height)))), ID = 3, Filter('Easy Sales',ProductCategory = "Table"), ID = 3 And Measure_gallery.Selected.Height = 0, (Filter('Easy Sales',(ProductCategory = "Table") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth)))), ID = 3 And Measure_gallery.Selected.Height > 0, (Filter('Easy Sales',(ProductCategory = "Table") And ((Depth < Measure_gallery.Selected.BoundingDepth And Width < Measure_gallery.Selected.BoundingWidth And Height <= Measure_gallery.Selected.Height) Or (Depth < Measure_gallery.Selected.BoundingWidth And Width < Measure_gallery.Selected.BoundingDepth And Height <= Measure_gallery.Selected.Height)))) )
重要
今後間違えることがないように、SharePoint リストとギャラリーに適切な名前を付けます。 混乱を避けるために、数式内のコンポーネントの名前を維持します。
Note
Carpets ページには空間フィルターは含まれていません。この製品に固有の別の機能が追加されているためです。 MR で測定セッションで測定された面積が、選択したカーペットの価格を見積もるために使用されます。
ヒント
上部にある [ファイル] タブを選択し、[保存] オプションを選択して、アプリケーションを頻繁に保存します。 メッセージが表示されたら [クラウド] オプションを選択し、次に [保存] を選択します。
面積に基づいて価格を計算する
Carpet_details ページに移動してから、ラベルを追加し、次に Area_carpets という名前に変更します。
Area_carpets ラベルの横に空白のラベルをもう 1 つ追加してから、その空白ラベルの Text プロパティを次のように構成して、計算された面積を表示するようにします。
Measure_gallery.Selected.Area&"cm²"
Price ラベルの横のラベルを次のように構成し、計算された価格を表示するようにします。
"$"&Measure_gallery.Selected.Area * content_carpets.'Price/cm2'
上記の手順を実装した後、アプリケーションによって、製品が空間的にフィルター処理され、実世界の測定値に基づいてカーペットの正確な価格が計算されます。