This seems very simple, but I cannot get it to work.
I have approx 20 items in a static data source (excel table), "Benchmark_Test", which are grouped under 5 categories, under the column "Parent".
I am trying to show only 5 distinct items in the gallery, 1 for each parent. So 1 item should display Parent1, the 2nd should display "Parent2", etc.
The following code, under 'items' for the gallery, does not work owing to the equals sign.
ilter(Benchmark_Test,Parent=Distinct(Benchmark_Test,thisitem.parent))
Any ideas? Thanks 🙂
Solved! Go to Solution.
Hi @Anonymous ,
Do you want to the Parent field display non-repeatingly?
Just setting the gallery's Items to this is ok.
Distinct(Benchmark_Test,Parent)
However, the gallery will only display the data of Parent, without other fields.
Distinct function will return a table with only one field named Result to display the Parent field non-repeatingly.
I think that's not what you need.
Do you want to display other fields at the same time?
If so, I suggest you try GroupBy function.
This function could be used to group table based on Parent field. In this way, the Parent field data will not repeat, other fields'data will be retained at the same time.
I've made a similar test for your reference:
1)insert one gallery
Set the gallery's Items:
GroupBy(Benchmark_Test,"Parent","otherdata")
2)insert a gallery inside the gallery
set the gallery2's Items:
ThisItem. otherdata //this gallery will display the data that have the same parent
Here's a doc about GroupBy function for your reference:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-groupby
Best regards,
You can use this expression for the Items property of the gallery:
Distinct(Benchmark_Test, Parent)
The Distinct function returns a table with a single column (called 'Result') that contains the distinct values for the given expression (in the example above, the values of the 'Parent' column).
Hope this helps!
Hi @Anonymous ,
Do you want to the Parent field display non-repeatingly?
Just setting the gallery's Items to this is ok.
Distinct(Benchmark_Test,Parent)
However, the gallery will only display the data of Parent, without other fields.
Distinct function will return a table with only one field named Result to display the Parent field non-repeatingly.
I think that's not what you need.
Do you want to display other fields at the same time?
If so, I suggest you try GroupBy function.
This function could be used to group table based on Parent field. In this way, the Parent field data will not repeat, other fields'data will be retained at the same time.
I've made a similar test for your reference:
1)insert one gallery
Set the gallery's Items:
GroupBy(Benchmark_Test,"Parent","otherdata")
2)insert a gallery inside the gallery
set the gallery2's Items:
ThisItem. otherdata //this gallery will display the data that have the same parent
Here's a doc about GroupBy function for your reference:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-groupby
Best regards,