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

Add the values in the number field

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.

 

Lana_0-1595870354889.png

 

What is wrong with my formula?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver I
Resolver I

Re: Add the values in the number field

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:

could not be bothered 2.jpg

 

 

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. 🙂

View solution in original post

7 REPLIES 7
Highlighted
Resolver I
Resolver I

Re: Add the values in the number field

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. 🙂

 

Highlighted
Helper II
Helper II

Re: Add the values in the number field

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 😄

Highlighted
Resolver I
Resolver I

Re: Add the values in the number field

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:

could not be bothered 2.jpg

 

 

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. 🙂

View solution in original post

Highlighted
Helper II
Helper II

Re: Add the values in the number field

Thank you for the logic.

 

I still can't figure out what is wrong in my flow. Can you take a look?

 

Lana_0-1595875266278.png

 

 

Lana_1-1595875327973.png

 

Highlighted
Resolver I
Resolver I

Re: Add the values in the number field

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. 😉

https://youtu.be/ClN6Tci38qk

Highlighted
Helper II
Helper II

Re: Add the values in the number field

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.

Highlighted
Resolver I
Resolver I

Re: Add the values in the number field

My pleasure, mate! Enjoy!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (5,977)