cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Counting Records in a Gallery using UpdateContext Variables

I'm creating an app with a SharePoint list as the data source.  I have a Status column that is a dropdown with Not Started, In progress, Completed, Cancelled as the different options.  I have a Gallery (RecordView) that has a list of all records.  The screen (MyHomeGallery) will show records based on what team they are on, so I don't want to count all the records of each Status in the list.  I'm trying to use the UpdateContext, outside the Gallery, to count the number of records for each type when the page loads.

 

I've tried a couple things with no success.  Here is what I have now in OnVisible of MyHomeGallery screen:

 

If(RecordView.Status.Text="Not Started",UpdateContext({status:"New"}),
RecordView.Status.Text="In Progress",UpdateContext({status:"InP"}),
RecordView.Status.Text="Completed",UpdateContext({status:"Comp"}),
RecordView.Status.Text="Cancelled",UpdateContext({status:"Canc"}))

 

I have a Label above(outside) the Gallery, at the top of MyHomeGallery screen that has in Text:

 

CountIf(RecordView.Status="New")

 

I've tried many different formulas and can't figure out what I'm doing wrong.

 

I appreciate any help!  Thanks!

 

 

5 REPLIES 5
Highlighted
Solution Supplier
Solution Supplier

Re: Counting Records in a Gallery using UpdateContext Variables

Try this code

CountIf(RecordView.AllItems, Status = "New")

--------------------------------------------------------------------

Please Accept as Solution if this post answered your question so other members can find it. If you found this post helpful consider giving my post a Thumbs Up!

Highlighted
Community Support
Community Support

Re: Counting Records in a Gallery using UpdateContext Variables

Hi @Kay_DeFries ,

 

Did you mean that you want to count the number of records for each kind of status? If so, then you should use below formulas in the Texy property of each label controls to show the numbers instead:

Label1.Text=CountRows(Filter(ListName,Status.Value="New"))
Label2.Text=CountRows(Filter(ListName,Status.Value="InP"))
Label3.Text=CountRows(Filter(ListName,Status.Value="Comp"))
Label4.Text=CountRows(Filter(ListName,Status.Value="Canc"))

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Frequent Visitor

Re: Counting Records in a Gallery using UpdateContext Variables

I do want to count all of the variables, but in different labels at the top of the screen.  I thought if I could get one to work, I could figure the rest out.

 

I tried your suggestion and am getting the error message:  Invalid argument type Location

 

Any other thoughts/suggestions?

 

Highlighted
Frequent Visitor

Re: Counting Records in a Gallery using UpdateContext Variables

@v-monli-msft @Edwin-Abdalian 

I tried both suggestions and am getting the error message:  Invalid argument type Location

 

Any other thoughts/suggestions?

Highlighted
Community Support
Community Support

Re: Counting Records in a Gallery using UpdateContext Variables

Hi @Kay_DeFries ,

 

What is the formula you use? And what is the column type of Location?

 

Regards,

Mona

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

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (9,861)