Hi there experts,
Would like a little help please. the scenario goes, that I have a sharepoint list called 'Entries', one column has the values of percentages. I want the user to be able to enter items (5-6) each with percentages and when the percentage total reaches 100, to show message and prevent further entries. Further more I want to restrict entries of (5-6) record for each user in a specific year, if he/she tries to enter next year app will allow it.
I have a 'Save button' to submit entries of a form, I want to add the check (where i read all lines in list within this year and under the same user name, then if the percentage not reached 100, to allow it). Something like the below code (with the right syntax ;))
If(User().FullName in Entries.Created_By,
Entries.Percentage (Get all records with the same user in this year) => when 100% reached show error, otherwise allow entry with notification on how much percentage remains to complete 100%. like below (25%+30%+40%) = 95% .
Can someone help me please, much appreciated.
Solved! Go to Solution.
Hi @Muhja ,
According to your description I did a simple test, I filter all the values in the current user percentage column to determine whether the sum of the values reaches 100%. If the value is greater than 1, an error message is displayed; if it is less than or equal to 1, the form record can be submitted and the remaining percentage is displayed.
Please refer to the formula in the screenshot:
If(
Sum(Filter(Entries,(Created >= Date(Text(varyear),1,1))&&('Created By'.Email = name)),percentages) + percentages_DataCard2.Update > 1,
Notify("Percentage reaches 100", NotificationType.Error),
SubmitForm(Form2);Notify( 1-Sum(Entries,percentages) & " remains to complete 100% " )
)
Best Regards,
Jessica Gu
Thank you Jessica,
That was quite helpful, I have used your approach and tweaked it a bit to fit my requirements. Here is how I did it for others to benefit from.
1- In the form I have created a drop down box an populated the percentages values needed, e.g. in the dropdown box Item controls:
["5%", "10%", "15%", "20%", etc.]
2- Created a label field, and in Text control added the following calculation to sum the entered values the user keeps saving every time he/she makes an entry and then clicks 'Save' (which is practically SubmitForm command with condition), code: Sum(Filter(DataSourceName,UserEmail=varUserEmail),PercentageValue).
3- Add another label field to show message resulting based on the sum value of the percentages. Concatenated some stuff to make the message presentable, Code:
If(Sum(Filter(DataSourceName,UserEmail=varUserEmail),PercentageValue)=1,Blank(),Concatenate("* Please check your entries, total of percentages not equal to 100%. Currently total is: ", (Sum(Filter(DataSourceName,UserEmail=varUserEmail),PercentageValue)*100),"%")).
4- on Submit button, add the check where the value of the label compared to 1. Code sample:
If (Value(Label1.Text) < 1 || Value(Label1.Text) > 1,
UpdateContext({ShowMessage: Notify("Please check percentages total must be exactly 100%", NotificationType.Error)}),
ForAll(RenameColumns(DataSourceName, "ID", "ID1"), Patch(DataSourceName, LookUp(DataSourceName, ID = ID1 && UserEmail = varUserEmail ), {Status: "Pending for Approval"})));
Hope this is helpful, appreciate the support.
Hi @Muhja ,
According to your description I did a simple test, I filter all the values in the current user percentage column to determine whether the sum of the values reaches 100%. If the value is greater than 1, an error message is displayed; if it is less than or equal to 1, the form record can be submitted and the remaining percentage is displayed.
Please refer to the formula in the screenshot:
If(
Sum(Filter(Entries,(Created >= Date(Text(varyear),1,1))&&('Created By'.Email = name)),percentages) + percentages_DataCard2.Update > 1,
Notify("Percentage reaches 100", NotificationType.Error),
SubmitForm(Form2);Notify( 1-Sum(Entries,percentages) & " remains to complete 100% " )
)
Best Regards,
Jessica Gu
Thank you Jessica,
That was quite helpful, I have used your approach and tweaked it a bit to fit my requirements. Here is how I did it for others to benefit from.
1- In the form I have created a drop down box an populated the percentages values needed, e.g. in the dropdown box Item controls:
["5%", "10%", "15%", "20%", etc.]
2- Created a label field, and in Text control added the following calculation to sum the entered values the user keeps saving every time he/she makes an entry and then clicks 'Save' (which is practically SubmitForm command with condition), code: Sum(Filter(DataSourceName,UserEmail=varUserEmail),PercentageValue).
3- Add another label field to show message resulting based on the sum value of the percentages. Concatenated some stuff to make the message presentable, Code:
If(Sum(Filter(DataSourceName,UserEmail=varUserEmail),PercentageValue)=1,Blank(),Concatenate("* Please check your entries, total of percentages not equal to 100%. Currently total is: ", (Sum(Filter(DataSourceName,UserEmail=varUserEmail),PercentageValue)*100),"%")).
4- on Submit button, add the check where the value of the label compared to 1. Code sample:
If (Value(Label1.Text) < 1 || Value(Label1.Text) > 1,
UpdateContext({ShowMessage: Notify("Please check percentages total must be exactly 100%", NotificationType.Error)}),
ForAll(RenameColumns(DataSourceName, "ID", "ID1"), Patch(DataSourceName, LookUp(DataSourceName, ID = ID1 && UserEmail = varUserEmail ), {Status: "Pending for Approval"})));
Hope this is helpful, appreciate the support.
User | Count |
---|---|
255 | |
106 | |
85 | |
51 | |
43 |