web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Power Apps taking long...
Power Apps
Answered

Power Apps taking long time to load data

(1) ShareShare
ReportReport
Posted on by 119
Hi Folks,

Greetings!

I'm creating PowerApps where data is loading on the screen visible property, before displaying data in PowerApps gallery I need to create column on the load and again want to push same column to the collection.
 
I'm using Dataverse as backend, Somehow I have implemented the logic to display data, but this formula taking too much time to load, though I have only five to 10 items in backend.

I just want to know is there any way that I can improve the app loading performance, or is there any other better way to do the same logic.
 
 
ClearCollect(
    colForActPO,
    ForAll(
        Gallery.AllItems As Items,
        {
            Value: DateValue(Items.txt_ForAct_FE_2.Text),
            Study: Items.Study,
            Name: Items.Name,
            TargetValue: DateValue(
                If(
                    IsBlank(Items.'Alloted FE Contract'),
                    "",
                    Text(
                        Coalesce(
                            Items.'Target FE Contract Days',
                            DateAdd(
                                _DviewStudy.cr246_first_site_init_dt,
                                -LookUp(
                                    Sourcing_Category_lead_times,
                                    Service = Items.Service,
                                    'Lead Time'
                                )
                            )
                        ),
                        "dd-mmm-yy"
                    )
                )
            ),
            Itemssourcing_status: If(
                (DateValue(Items.txt_ForAct_FE.Text) > DateValue(Items.txt_Target_FE.Text)) && !(Items.'Sourcing Outcome' = "Cancelled") && IsBlank(Items.'FE Contract Completion'),
                "At Risk",
                If(
                    (DateValue(Items.txt_ForAct_FE.Text) <= DateValue(Items.txt_Target_FE.Text)) && !(Items.'Sourcing Outcome' = "Cancelled") && IsBlank(Items.'FE Contract Completion') && !IsBlank(Items.'Allotted WRF Completion'),
                    "On Track",
                    If(
                        Items.'Sourcing Outcome' <> "Cancelled" && IsBlank (Items.'WRF Completion') && IsBlank(Items.'FE Contract Completion') && IsBlank(Items.'Allotted WRF Completion') && !IsBlank(Items.'Target FE Contract Days'),
                        "Planned",
                        If(
                            !IsBlank(Items.'FE Contract Completion'),
                            "Completed"
                        )
                    )
                )
            )
        }
    )
);
ForAll(
    colForActPO As Items,
    Patch(
        mainColl,
        LookUp(
            Sourcing_Study_Services,
            Name = Items.Name
        ),
        {sourcing_status: Items.Itemssourcing_status}
    )
);


 
Categories:
I have the same question (0)
  • Verified answer
    AmínAA Profile Picture
    1,228 Super User 2025 Season 2 on at
    Greetings @sachinsoni441!
     
    There are quite a lot of ways to improve functions... I didn't delve too deep into your specific function, which is fairly large, but here are some fast tips on how to improve your function's times...
    • You'd do good in avoiding a "Patch()" function inside a "ForAll()" function. There are faster ways of bulk patching items... Here's a post from Matthew Daveney on patching multiple records. Matthew Devaney - PATCH Multiple Records In Power Apps 10x Faster.
    • Use formulas fields in Dataverse whenever there's something that can be calculated on Dataverse, thus pushing some of the load onto the backend.
    • Try to avoid using collections if they’re not really needed.
    • If you must use collections to get data from any data source, such as Dataverse in your case, try to only collect relevant data, and not the whole table. (Yes, this includes taking only records you need, and columns you need).
     
    Bear in mind that having 10 records doesn’t mean it’s going to be fast, if you’re reading those 10 records 1000 times, either because your function is flawed, or any other reason (Not saying yours is doing it, but it’s a way to understand why 10 records might take more time than expected). 

    If you like my response, please give it a Thumbs Up. Should this reply solve your question, please mark your post as Solved. Otherwise, feel free to reply to my answer for further help.
    Connect with me if you feel like it! 
  • Suggested answer
    BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at
     
    When removing the nested If functions and applying the first suggestion from Aminaa, this is what your formula may look like:
    ClearCollect(
        colForActPO,
        ForAll(
            Gallery.AllItems As Items,
            {
                Value: DateValue(Items.txt_ForAct_FE_2.Text),
                Study: Items.Study,
                Name: Items.Name,
                TargetValue: DateValue(
                    If(
                        IsBlank(Items.'Alloted FE Contract'),
                        "",
                        Text(
                            Coalesce(
                                Items.'Target FE Contract Days',
                                DateAdd(
                                    _DviewStudy.cr246_first_site_init_dt,
                                    -LookUp(
                                        Sourcing_Category_lead_times,
                                        Service = Items.Service,
                                        'Lead Time'
                                    )
                                )
                            ),
                            "dd-mmm-yy"
                        )
                    )
                ),
                sourcing_status: If(
                    (DateValue(Items.txt_ForAct_FE.Text) > DateValue(Items.txt_Target_FE.Text)) && !(Items.'Sourcing Outcome' = "Cancelled") && IsBlank(Items.'FE Contract Completion'),
                    "At Risk",
                    (DateValue(Items.txt_ForAct_FE.Text) <= DateValue(Items.txt_Target_FE.Text)) && !(Items.'Sourcing Outcome' = "Cancelled") && IsBlank(Items.'FE Contract Completion') && !IsBlank(Items.'Allotted WRF Completion'),
                    "On Track",
                   Items.'Sourcing Outcome' <> "Cancelled" && IsBlank (Items.'WRF Completion') && IsBlank(Items.'FE Contract Completion') && IsBlank(Items.'Allotted WRF Completion') && !IsBlank(Items.'Target FE Contract Days'),
                   "Planned",
                   !IsBlank(Items.'FE Contract Completion'),
                   "Completed"
                )
            }
        )
    );
    Patch(
        mainColl,
        ShowColumns(colForActPO, Name, sourcing_status)
    );
     
    Please note I renamed the Itemssourcing_status column in the colForActPO collection to sourcing_status to match the column name in the mainColl for the patching tip to work. Any references to this column will break because of the change and will have to be repaired to restore functionality.
     
     
    If this reply helped you in any way, please give it a Like 💜 and in case it resolved your issue, please mark it as the Verified Answer ✅.
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    A bit hard to provide feedback without understanding the functionality.
     
    What functionality are you providing in this screen with this code?
     
    If the gallery is some kind of dashboard we can use the psychological approach by showing a spinner and a message "Generating Dashboard". Users will probably forgive you for the amount of time that it takes to load.
     
    Does the screen also display maincoll? If not, why are you generating it here?
     
    Can any of those date calculations be added as calculated columns in Dataverse?
     
    Can a new table be created which maintains at least some of this information and be updated as transactions take place reducing the amount of expression that you are using?
  • stampcoin Profile Picture
    5,058 Super User 2025 Season 2 on at
    The good thing is your did it in your logic way. 
    I modified the code a little bit.
    1. The innermost layer, there is a lookup , it will check the database each time. so collect that in a local collection.
    2. the second patch part, use patch at once rather patch one by one.
    3. the date transformation part, can be optimized, but first two is the most importtant one, you can think about this after 1 and 2.
    //Load Sourcing_Category_lead_times
    ClearCollect(colLeadTimes, Sourcing_Category_lead_times);
    
    ClearCollect(
        colForActPO,
        ForAll(
            Gallery.AllItems As Items,
            {
                Value: DateValue(Items.txt_ForAct_FE_2.Text),
                Study: Items.Study,
                Name: Items.Name,
                TargetValue: DateValue(
                    If(
                        IsBlank(Items.'Alloted FE Contract'),
                        "",
                        Text(
                            Coalesce(
                                Items.'Target FE Contract Days',
                                DateAdd(
                                    _DviewStudy.cr246_first_site_init_dt,
                                    -LookUp(
                                        colLeadTimes,
                                        Service = Items.Service,
                                        'Lead Time'
                                    )
                                )
                            ),
                            "dd-mmm-yy"
                        )
                    )
                ),
                Itemssourcing_status: If(
                    (DateValue(Items.txt_ForAct_FE.Text) > DateValue(Items.txt_Target_FE.Text)) && !(Items.'Sourcing Outcome' = "Cancelled") && IsBlank(Items.'FE Contract Completion'),
                    "At Risk",
                    If(
                        (DateValue(Items.txt_ForAct_FE.Text) <= DateValue(Items.txt_Target_FE.Text)) && !(Items.'Sourcing Outcome' = "Cancelled") && IsBlank(Items.'FE Contract Completion') && !IsBlank(Items.'Allotted WRF Completion'),
                        "On Track",
                        If(
                            Items.'Sourcing Outcome' <> "Cancelled" && IsBlank (Items.'WRF Completion') && IsBlank(Items.'FE Contract Completion') && IsBlank(Items.'Allotted WRF Completion') && !IsBlank(Items.'Target FE Contract Days'),
                            "Planned",
                            If(
                                !IsBlank(Items.'FE Contract Completion'),
                                "Completed"
                            )
                        )
                    )
                )
            }
        )
    );
    // One single batch Patch rather than 1 by 1.
    Patch(
      mainColl,
      ForAll(
        colForActPO As Items, 
        { ID: LookUp(mainColl, Name = U.Name, ID), sourcing_status: Items.Itemssourcing_status }
      )
    )
    
    
    Good luck.
     
  • AmínAA Profile Picture
    1,228 Super User 2025 Season 2 on at
    Hi there @sachinsoni441!
     
    Do you require any further help with this?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard