I am trying to save a calculated result that is rendered in a label control to a column in SharePoint named AmountEuro
In my label I have the following code to calculate the allowance and this works as expected:
With({KM:Value(DataCardValueKm.Text),AL:First(Filter(PayrollDefaults,Title="Default")).KmAllowance},KM * AL)
So on my submit button the calculated result should be saved to AmountEuro, anyone has any suggestions on what the best approach would be in this scenario? Any guidance is most appreciated.
@Lorem1960
Consider the following change to your label formula first:
With({KM: Value(DataCardValueKm.Text), AL: LookUp(PayrollDefaults, Title="Default").KmAllowance},
KM * AL
)
This is more efficient as it will cycle through the records of your datasource to find the first record that has Title of "Default" - then it returns it and stops.
In your existing formula, you are filtering ALL the records and then returning all the matching records, then using the First function to get the first one of the table. So, that is much more data being transmitted and pulled into memory and then discarded.
As for putting it into SharePoint...are you doing this through a form? Or do you have some other logic for where and how you are going to put the value into SharePoint?
Interesting, ok, so yes I am using a form which is in New mode, so when the user clicks on submit the result of the calculation needs to be persisted in the SharePoint column.
So then you should have the field in your form that you want the value to go into, and then in that datacard, set the DataCardValuex control Default property to: Coalesce(Parent.Default, yourLabel.Text)
Unfortunately it doesn't seem to like this I get an error
Well you have a circular reference!
Where is the label? You mentioned that the formula you had was in a label - I assume that is CalcAllowance in your app.
The problem is, your label is referencing the DataCardValueAmountEuro and yet you are trying to set the default property of that same textinput. That will not work!
However, I am not seeing that from your formula from before - so what is DataCardValueKM and how is that derived?
In my label CalcAllowance is have the following:
With({KM: Value(DataCardValueKm.Text), AL: LookUp(PayrollDefaults, Title="Default").KmAllowance}, KM * AL )
And the values in DataCardValueKM are entered manually, but after given it some thought there is not really a need to store the calculated result on a column. Thanks.
Yes, that was a consideration that I had to start with...usually visual calculations are not something that needs to be stored.
So, if you are not needing to store the value, then you should be good.
User | Count |
---|---|
252 | |
107 | |
88 | |
51 | |
44 |