I have a field(field type is number) in my SharePoint list called "HowManyDays". I want to add all the number in the field for all the items.
ID HowManyDays
1 5
2 7
3 4
I want to calculate the total 16 in my variable.
What is wrong with my formula?
Solved! Go to Solution.
Nono, it's all good, plus I should've assumed that you knew that ... it just wasn't mentioned is all.
And you're right, it's just a bit of an arse, and because I couldn't be bothered to over think an elegant solution, here's how I did it:
I'm sure you could slim that down.
Essentially, though, the addition couldn't go in the setting of its own value, and there's no increment using the basic functions, so we needed to separate out with an extra variable.
add(variables('howManyDaysVAR'), int(items('Apply_to_each')?['HowManyDays']))
Oh, and because I hadn't locked down the decimals in the SharePoint list Power Automate read the SP value as a float, instead of an integer. So that " int() " that's around the SharePoint call is me making up for my mistake by using the expression that converts a value to an integer. 😉
All good. 🙂
Hi, @Lana , I think it's because you're not running it in an Apply to each action.
You need to do the same thing for each item that the flow reads from the SharePoint list.
Will edit in pictures if needed once I've done a demo, but I think you'll get the point. 🙂
Yeah I figured I am missing Apply to each.
But still looking into how I will store the previous value and add it to the next item value.
Sorry a newbie to Power Automate 😄
Nono, it's all good, plus I should've assumed that you knew that ... it just wasn't mentioned is all.
And you're right, it's just a bit of an arse, and because I couldn't be bothered to over think an elegant solution, here's how I did it:
I'm sure you could slim that down.
Essentially, though, the addition couldn't go in the setting of its own value, and there's no increment using the basic functions, so we needed to separate out with an extra variable.
add(variables('howManyDaysVAR'), int(items('Apply_to_each')?['HowManyDays']))
Oh, and because I hadn't locked down the decimals in the SharePoint list Power Automate read the SP value as a float, instead of an integer. So that " int() " that's around the SharePoint call is me making up for my mistake by using the expression that converts a value to an integer. 😉
All good. 🙂
Thank you for the logic.
I still can't figure out what is wrong in my flow. Can you take a look?
Looking at the error it's telling you what it's being passed can't be converted to an integer, so it looks like all is fine, it's just what's going in there isn't.
Taking a closer look, hang on.
I actually have to run off, but if you separate out the logic, and create the integer outside of that addition step, then you can remove it from there, and chase the error.
My guess is that you maybe have to get the value yourself, instead of typing out my code (not assuming you are ... just a stab in the dark) ...
You need to cut that item that's in your Compose there, and paste it into your int() formula ...
Will check back with you later. 🙂
Here's a quick video that I made (with a flow done for this issue here) to show you how to easily steal the right reference values, and I even externalised the int() in that one, too. 😉
That's a very cool trick. I learnt something new today!
I was able to fix my issue too. Thank you so much for all your help.
My pleasure, mate! Enjoy!
User | Count |
---|---|
23 | |
15 | |
14 | |
10 | |
9 |
User | Count |
---|---|
45 | |
29 | |
25 | |
24 | |
22 |