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
)
)
)
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.
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!
User | Count |
---|---|
167 | |
90 | |
73 | |
65 | |
58 |
User | Count |
---|---|
213 | |
153 | |
97 | |
88 | |
66 |