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

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
Edwin-Abdalian
Level 10

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!

Community Support Team
Community Support Team

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.
Kay_DeFries
Level: Powered On

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?

 

Kay_DeFries
Level: Powered On

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?

Community Support Team
Community Support Team

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
thirdimage

Power Apps Super User Class of 2020

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 (Last 30 Days)
Users online (5,639)