cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MaxDonen
Level: Powered On

How to show only distinct items in a gallery?

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 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to show only distinct items in a gallery?

Hi @MaxDonen ,

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 


1017_LI.jpg

 

10172_LI.jpg

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: How to show only distinct items in a gallery?

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!

Community Support Team
Community Support Team

Re: How to show only distinct items in a gallery?

Hi @MaxDonen ,

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 


1017_LI.jpg

 

10172_LI.jpg

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,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,014)