cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Willo
Helper II
Helper II

Load sreen finishes before the collection is finished loading

Hello everyone, 

 

Can someone share why my loading screen may be finishing before the data is finished being collected? This is my functions

 

Set(
    WBLoading,
    true
);
Set(
    VarSelecteduser,
    Office365Users.MyProfileV2().userPrincipalName
);
Concurrent(
    Set(
        VarSelecteduserphoto,
        Office365Users.UserPhoto(VarSelecteduser)
    ),
    Set(
        VarSelecteduserName,
        Office365Users.MyProfileV2().displayName
    ),
    Set(
        VarSelecteduserDeparment,
        Office365Users.MyProfileV2().department
    ),
    Set(
        VarSelecteduserLocation,
        Office365Users.MyProfileV2().city
    ),
    Set(
        VarSelecteduserEmail,
        Office365Users.MyProfileV2().mail
    );
    Concurrent(
        If(
            VarProfile.Access_Level.Value = "TM",
            ClearCollect(
                WelcomeBackData,
                Filter(
                    AbsenceData,
                    StartsWith(
                        MonthShort,
                        REFVariShortMonth.Text
                    ),
                    Year = REFVariYear.Text,
                    VarSelecteduserEmail = ManagerEmail
                )
            ),
            ClearCollect(
                WelcomeBackData,
                Filter(
                    AbsenceData,
                    StartsWith(
                        MonthShort,
                        REFVariShortMonth.Text
                    ),
                    Year = REFVariYear.Text,
                    VarSelecteduserEmail = SenoirManagerEmail
                )
            )
        ),
        If(
            VarProfile.Access_Level.Value = "TM",
            ClearCollect(
                CheckInData,
                Filter(
                    Check_in_Data,
                    StartsWith(
                        Short_Month,
                        REFVariShortMonth.Text
                    ),
                    Year = REFVariYear.Text,
                    VarSelecteduserEmail = TM_Email
                )
            ),
            ClearCollect(
                CheckInData,
                Filter(
                    Check_in_Data,
                    StartsWith(
                        Short_Month,
                        REFVariShortMonth.Text
                    ),
                    Year = REFVariYear.Text,
                    VarSelecteduserEmail = SM_Email
                )
            )
        ),
        If(
            VarProfile.Access_Level.Value = "TM",
            ClearCollect(
                Top_10_Data,
                Filter(
                    Top10Data,
                    StartsWith(
                        Short_Month,
                        REFVariShortMonth.Text
                    ),
                    Year = REFVariYear.Text,
                    VarSelecteduserEmail = TM_Email
                )
            ),
            ClearCollect(
                Top_10_Data,
                Filter(
                    Top10Data,
                    StartsWith(
                        Short_Month,
                        REFVariShortMonth.Text
                    ),
                    Year = REFVariYear.Text,
                    VarSelecteduserEmail = SM_Email
                )
            )
        );
        Set(
            WBLoading,
            false
        )
    )
)

 

@smartin 

2 REPLIES 2
RandyHayes
Super User
Super User

@Willo 

So first, where is this formula?  Why so many variables?

You might consider simplifying your formula to the following:

Set(WBLoading, true);

Set(VarSelecteduser,
    With({lclUsr: Office365Users.MyProfileV2()},
        {PrincipalName: lclUsr.userPrincipalName,
         Photo: Office365Users.UserPhoto(User().Email),
         Name: lclUsr.displayName,
         Department: lclUser.department,
         City: lclUsr.city,
         Mail: lclUsr.mail
        }
    )
);

ClearCollect(
    WelcomeBackData,
    Filter(AbsenceData,
        StartsWith(MonthShort, REFVariShortMonth.Text),
        Year = REFVariYear.Text,
        VarSelecteduserEmail = If(VarProfile.Access_Level.Value = "TM", ManagerEmail, SenoirManagerEmail)
    )
);
           
ClearCollect(CheckInData,
    Filter(Check_in_Data,
        StartsWith(Short_Month, REFVariShortMonth.Text),
        Year = REFVariYear.Text,
        VarSelecteduserEmail = If(VarProfile.Access_Level.Value = "TM", TM_Email, SM_Email)
    )
);

ClearCollect(Top_10_Data,
    Filter(Top10Data,
        StartsWith(Short_Month, REFVariShortMonth.Text),
        Year = REFVariYear.Text,
        VarSelecteduserEmail = If(VarProfile.Access_Level.Value = "TM", TM_Email, SM_Email)
    )
);

Set(WBLoading, false)

 

What do some of these items refer to?  And actually this is more a question in context with the "Where is this" question.  If you are trying to do this in an OnStart or OnVisible, you might not have actual values in some of the things you are referencing. 

 

And finally in reference to the loading of data.  Check your advanced settings and see if you have Delayed Load on.  If so, you might want to consider turning that off.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
CarlosFigueira
Power Apps
Power Apps

This expression is setting the 'WBLoading' variable to false concurrently with the expressions that fetch data into the collection. Setting a variable is a very quick operation, so it will certainly complete before a network call is made. If you move the 'Set(WBLoading, false)' to outside the Concurrent call, it should wait until the collections are finished loading.

Another issue in this expression is that it is setting the 'VarSelecteduserEmail' variable concurrently with trying to use it, so it's possible that it will not be properly fetched before it is used. And yet another performance improvement that can be made is to call the 'Office365Users.MyProfileV2()' function only once. Take a look at the expression below with the suggested changes:

Set(WBLoading, true);
Set(VarSelecteduserProfile, Office365Users.MyProfileV2());
Set(VarSelecteduser, VarSelecteduserProfile.userPrincipalName);
Set(VarSelecteduserName, VarSelecteduserProfile.displayName);
Set(VarSelecteduserDeparment, VarSelecteduserProfile.department);
Set(VarSelecteduserLocation, VarSelecteduserProfile.city);
Set(VarSelecteduserEmail, VarSelecteduserProfile.mail);
Concurrent(
    Set(VarSelecteduserphoto, Office365Users.UserPhoto(VarSelecteduser)),
    If(
        VarProfile.Access_Level.Value = "TM",
        ClearCollect(
            WelcomeBackData,
            Filter(
                AbsenceData,
                StartsWith(MonthShort, REFVariShortMonth.Text),
                Year = REFVariYear.Text,
                VarSelecteduserEmail = ManagerEmail
            )
        ),
        ClearCollect(
            WelcomeBackData,
            Filter(
                AbsenceData,
                StartsWith(MonthShort, REFVariShortMonth.Text),
                Year = REFVariYear.Text,
                VarSelecteduserEmail = SenoirManagerEmail
            )
        )
    ),
    If(
        VarProfile.Access_Level.Value = "TM",
        ClearCollect(
            CheckInData,
            Filter(
                Check_in_Data,
                StartsWith(Short_Month, REFVariShortMonth.Text),
                Year = REFVariYear.Text,
                VarSelecteduserEmail = TM_Email
            )
        ),
        ClearCollect(
            CheckInData,
            Filter(
                Check_in_Data,
                StartsWith(Short_Month, REFVariShortMonth.Text),
                Year = REFVariYear.Text,
                VarSelecteduserEmail = SM_Email
            )
        )
    ),
    If(
        VarProfile.Access_Level.Value = "TM",
        ClearCollect(
            Top_10_Data,
            Filter(
                Top10Data,
                StartsWith(Short_Month, REFVariShortMonth.Text),
                Year = REFVariYear.Text,
                VarSelecteduserEmail = TM_Email
            )
        ),
        ClearCollect(
            Top_10_Data,
            Filter(
                Top10Data,
                StartsWith(Short_Month, REFVariShortMonth.Text),
                Year = REFVariYear.Text,
                VarSelecteduserEmail = SM_Email
            )
        )
    )
);
Set(WBLoading, false)

Hope this helps!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,379)