如何在 PowerApps 中获取不同的图库磁贴? [英] How to get distinct Gallery tiles in PowerApps?

查看:52
本文介绍了如何在 PowerApps 中获取不同的图库磁贴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 PowerApps 数据源是 Excel 表格.用户输入后,excel表格如下所示.在下图中,您可以看到Sys1"在 Excel 表格中出现两次,导致在 PowerApps 中为同一个系统库创建一个额外的磁贴.我的问题是如何避免在 PowerApps 中重复创建磁贴?下面是 Gallery 和 Tile 的代码.我是 PowerApps 的新手.提供带有解释的代码.

My DataSource for PowerApps is Excel Table. After user's Entry, the excel Table looks like below. In below image one can see that "Sys1" appears twice in Excel Table, leading to creating one extra tile for same system Gallery in PowerApps.My Question is How to avoid duplication of tile creation in PowerApps ? Below is code for Gallery and Tile. I am new to PowerApps. Provide code with explanation .

注意:我忘记在 Sys 后面添加 Name.下面截图中的第一列名称应为系统名称"

Note: I forgot to add Name after Sys. The 1st column name in below screenshot should be "Sys Name"

图库 -> 项目属性 [CODE]

Filter(Table1,Startswith('Sys Name'),"Sys"))

瓷砖 ->文本属性 [CODE]

ThisItem.'Sys Name'

推荐答案

要删除重复项,您可以使用 GroupBy 函数 并采用 每个组中元素的第一个.一旦你有了它,你就可以使用一些 table如有必要,整形函数(AddColumns、DropColumns) 以重新创建原始列结构:

To remove duplicates you can use the GroupBy function and take the First of the elements in each group. Once you have that, you can use some of the table shaping functions (AddColumns, DropColumns) to recreate the original column structure, if necessary:

DropColumns(
    AddColumns(
        GroupBy(
            Filter(Table1, StartsWith('Sys',"Sys")),
            "Sys",
            "BySys"),
        "Model#", First(BySys).'Model#',
        "Current Status", First(BySys).'Current Status',
        "Previous Status", First(BySys).'Previous Status'),
    "BySys")

您可以从内到外读取上述表达式的方式:首先仅过滤Sys"列以Sys"开头的那些行的 Table1;(你最初拥有的).过滤器的结果将按 'Sys' 列分组,所有具有相似值的行都分组在 'BySys' 列中.对于此结果,我们通过采用分组元素中的第一个添加三列:模型#"、当前状态"和先前状态".最后,我们移除最外层函数的分组列 ('BySys').

The way you can read the expression above is from inside out: first filter the Table1 only for those rows whose 'Sys' column starts with "Sys" (what you had originally). The result of the filter will be grouped by the 'Sys' column, with all rows that have similar values grouped in the 'BySys' column. To this result, we add three columns: 'Model#', 'Current Status' and 'Previous Status', by taking the first of the grouped elements. Finally we remove the grouped column ('BySys') at the outermost function.

如果您不想在表达式中列出原始数据源的所有属性,您可以保留 GroupBy 表达式作为您图库的项目:

If you don't want to have to list all of the properties of the original data source in the expression, you can stay with the GroupBy expression as the Items of your gallery:

GroupBy(
    Filter(Table1, StartsWith('Sys',"Sys")),
    "Sys",
    "BySys")

在图库模板中,您可以有一个标签,将Sys"列直接显示为 ThisItem.Sys,但如果您想访问其他列,则需要从组,你想显示什么.例如,要显示该特定Sys"值的第一行的型号,您可以将此表达式作为标签的 Text 属性:

In the gallery template, you can have a label that shows the 'Sys' column directly as ThisItem.Sys, but if you want to access the other columns, you will need to choose, from the group, what you want to display. For example, to display the model number of the first row for that specific 'Sys' value, you can have this expression as the Text property of a label:

First(ThisItem.BySys).'Model#'

另一种选择,如果您想显示许多其他属性并且不想继续重复调用 First 是将其添加为图库项目的另一个(记录)属性:

Yet another option, if you want to show many other properties and don't want to keep repeating the call to First is to add that as another (record) property of the gallery items:

AddColumns(
    GroupBy(
        Filter(Table1, StartsWith('Sys',"Sys")),
        "Sys",
        "BySys"),
    "FirstSys", First(BySys))

现在在您的图库中,您可以拥有具有以下属性的标签:

And now in your gallery you can have labels with the following properties:

ThisItem.FirstSys.'Model#'
ThisItem.FirstSys.'Current Status'

等等.

这篇关于如何在 PowerApps 中获取不同的图库磁贴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆