cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

Add / Remove items from a Collection based on Visible Property

I'd like to build a progress bar based on how many questions a user has completed thus far in a 40-50 field form. Every field is required. I've set the asterisks of each card to visible=false when a user enters data. 

 

My thought is that I'll base the progress bar on the # of asterisks that are visible. I can't figure out how to accomplish this. I think the solution is something like: 

 

When screen loads: 

ClearCollect(colProgress, 

    {field: name, vis: If( name_star.visible, 0,1)},

    {field: date, vis: If( date_star.visible, 0,1)},

    {field: size, vis: If( size_star.visible, 0,1)},

    {field: pattern, vis: If( pattern_star.visible, 0,1})

 )

 

The Textbox/Shape for the progres bar is:

 

Sum(colProgress.vis,vis)

 

This all works great, however:

 

My problem:

  • How do I update the collection when a field is completed by user and the asterisk disappears? 
    • I don't want to ClearCollect each time a field is completed, this I think will affect performance. 

Any ideas? 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Add / Remove items from a Collection based on Visible Property

Hi @dinusc. Thank you very much for the response. I did indeed end up using various combinations of Update in the OnChange Property. 

 

For Person Lookup fields: 

If(
    IsBlank(name.Selected.DisplayName),   
        Update(
            colProgressBar,
                First(
                    Filter(
                        colProgressBar,
                        field = "name")),
                {field: "name", vis: 0}),
        Update(
            colProgressBar,
                First(
                    Filter(
                        colProgressBar,
                        field = "name")),
                {field: "name", vis: 1})
)

For DateTime dropdowns, I put the following code in all 3 fields (datepicker, hour, minute dropdowns):

If(
    Or(
        IsBlank(date_datepicker),
        hour.Selected.Value = " ",
        minute.Selected.Value = " "),
        Update(
            colProgressBar,
                First(
                    Filter(
                        colProgressBar,
                        field = "date")),
                {field: "date", vis: 0}),
        Update(
            colProgressBar,
                First(
                    Filter(
                        colProgressBar,
                        field = "date")),
                {field: "date", vis: 1})
)

 

 

View solution in original post

2 REPLIES 2
Microsoft
Microsoft

Re: Add / Remove items from a Collection based on Visible Property

Hello Eric,I will start by saying that I don't think running ClearCollect on 50 rows will be a performance issue even on an oldest mobile device that supports PowerApps.

If you still want to update a collection, have you considered "Update" function? Something like:

Update(colProgress, LookUp(colProgress, field=date), {field: date, vis: If( date_star.visible, 0,1)})

 

Highlighted
Super User
Super User

Re: Add / Remove items from a Collection based on Visible Property

Hi @dinusc. Thank you very much for the response. I did indeed end up using various combinations of Update in the OnChange Property. 

 

For Person Lookup fields: 

If(
    IsBlank(name.Selected.DisplayName),   
        Update(
            colProgressBar,
                First(
                    Filter(
                        colProgressBar,
                        field = "name")),
                {field: "name", vis: 0}),
        Update(
            colProgressBar,
                First(
                    Filter(
                        colProgressBar,
                        field = "name")),
                {field: "name", vis: 1})
)

For DateTime dropdowns, I put the following code in all 3 fields (datepicker, hour, minute dropdowns):

If(
    Or(
        IsBlank(date_datepicker),
        hour.Selected.Value = " ",
        minute.Selected.Value = " "),
        Update(
            colProgressBar,
                First(
                    Filter(
                        colProgressBar,
                        field = "date")),
                {field: "date", vis: 0}),
        Update(
            colProgressBar,
                First(
                    Filter(
                        colProgressBar,
                        field = "date")),
                {field: "date", vis: 1})
)

 

 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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