cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sajarac
Level 8

Count items in a gallery

Hi there,

 

Quick question here?

 

I have a gallery with a couple of labels, one of the labels is the result of a radio button with items "Single" and "Double" I would like to add outside of that gallery to labels to show the total value of:

 

Total Singles :

 

Total Doubles:

 

Could someone point me in the right direction?

 

Thanks in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
BrianR
Level 10

Re: Count items in a gallery

Yes,

But let's say your radio box (let's call it Radio1) that is within the gallery looks like this:

radiobox.PNG

 ie: where Items = [ "Single", "Double" ]

so your filters would be:

 

  • Total Items in the Gallery:   CountRow( Gallery1.AllItems )
  • Num where Radio is Single:  CountRows( Filter( Gallery1.AllItems, Radio1.Selected.Value = "Single" ) )

  • Num where Radio is Double:  CountRows( Filter( Gallery1.AllItems, Radio1.Selected.Value = "Double" ) )

You'll want to double check the syntax in the filter, but I believe this is correct.

View solution in original post

6 REPLIES 6
BrianR
Level 10

Re: Count items in a gallery

If the name of the gallery is Gallery1, you can (outside of the gallery) get the number of items in the gallery using:

CountRows( Gallery1.AllItems )


The AllItems here is the key as it references each "row" in the gallery.  I'd imagine you could use Gallery1.AllItems and filter it before doing the CountRows() in order to see how many of each were "single" or "double".  

 

Hope this helps!

Anonymous
Not applicable

Re: Count items in a gallery

Hi sajarac 

As an idea you could define a variable when each radio button is selected, then use the CountRows function to count rows in the gallery that is filtered by that variable / radio button selection?

 

Radio button OnSelect:

UpdateContext({ItemSelection: Radiobutton.Selected.Value})

 

 

Then the row count might be displayed in a label with Text:

CountRows(Filter(Collection, [Column used to determine Single/Double] = ItemSelection))
sajarac
Level 8

Re: Count items in a gallery

Wow, thank you very much for this prompt response.

 

So you mean apply two filters?

BrianR
Level 10

Re: Count items in a gallery

Yes,

But let's say your radio box (let's call it Radio1) that is within the gallery looks like this:

radiobox.PNG

 ie: where Items = [ "Single", "Double" ]

so your filters would be:

 

  • Total Items in the Gallery:   CountRow( Gallery1.AllItems )
  • Num where Radio is Single:  CountRows( Filter( Gallery1.AllItems, Radio1.Selected.Value = "Single" ) )

  • Num where Radio is Double:  CountRows( Filter( Gallery1.AllItems, Radio1.Selected.Value = "Double" ) )

You'll want to double check the syntax in the filter, but I believe this is correct.

View solution in original post

sajarac
Level 8

Re: Count items in a gallery

Thank you very much for your prompt response!!!

BrianR
Level 10

Re: Count items in a gallery

Glad to be of help.  I was working in a gallery this evening (see my other post) and this was easy for me to try at the time.  🙂

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (7,817)