cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
deankingdk
Regular Visitor

Help with adding two values together in Power Automate (Flow)

Hi all.

 

Wondering if anybody could help me?

 

I have two separate SharePoint lists. One is called Holiday requests, one is called Holiday allocation.

 

I'm creating a Flow that basically does the following:

 

When a new item is created in the Holiday request list, find an item in the Holiday allocation list and then update it.

 

So far it's working all besides one thing. I can't get the Flow to add two values together for the life of me, it find the entry fine and can update the entry but the only way I can get it to work is to replace a value with the new one and not add both together.

 

Example:

  1. I enter my own details into the the Holiday request list, I enter my name and my days taken.
  2. In the Holiday allocation list, I have already populated my details in an entry, so my name will be down as Dean King, my days taken will be down as let's say 10 (assuming I've already booked some previous days etc).
  3. What I want the Flow to do is to see the new entry in the Holiday request list (it does this fine) then find the matching name in the Holiday allocation list (it also does the fine) and update the 'Days taken' field to show the value of the days request + the days I already had in the Holiday allocation list

So basically; Add 'Days requested' (from the Holiday request list) and 'Days taken' (from the Holiday allocation list) together and update the Days taken cell to the combined value.

 

Both of the days request and days remaining would be entered as numbers.

8 REPLIES 8
RobElliott
Super User
Super User

Hi @deankingdk you can do it like this. The HolidayAllocation list has your name in the Title column (which must be unique) and a DaysTaken number column. The HolidayRequest list has your name in the Title column (which of course won't be unique as you'll submit multiple holiday requests) and a DaysRequested number column. I've renamed the Get item below to Get item that was created.
0-trigger.png

Add a Get items and we want to just bring back your entry in the Holiday Allocation list. So in the advanced options add a filter query of Title eq '{Title}putting the Title column you selected from the Get item that was created section of the dynamic content inside apostrophes.

1-getAllocation.pngAdd a Compose control for the DaysTaken from the HolidayAllocation list. That will wrap it in an Apply to each. Everything from here on is inside the Apply to each. Add another Compose control for the DaysRequested from HolidayRequest list:

2-ApplytoEach-Compose.png

Add another Compose control and add the outputs of those 2 Compose controls together using an expression  of

add(outputs('Compose_DaysTaken'),outputs('Compose_DaysRequested'))
and you can select the outputs part of this from the Dynamic Content tab even though you're working in the Expression tab.

Then update the HolidayAlllocation list with the output of the addition.

3-Addition-Update.png

The result is as follows:
4-SP-list.png

Rob

Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

Hi Rob.

 

Appreciate the reply, just trying it now, keeps failing at this point. The 'Employee' column in the Holiday allocation list is set to People so would need to use the Dynamic content for it?

 

Any ideas?

 

 

Screenshot 2020-01-07 at 3.27.45 PM.png

 

Hi @deankingdk,

 

Unfortunately, Filter query in the Get items does not support Person type, you could consider using the Filter query action after add Get items action without any filter query:

Annotation 2020-01-08 163305.png

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@deankingdk as well as the filter array solution suggested by @v-litu-msft you can also use arrays and a condition to check if the Employee DisplayName of the Get items from the Allocation list is equal to the Employee DisplayName of the item that was created. If it isn't then do nothing, if it is then do the actions from my previous post. It's working well for me and updates the days taken for that employee.

10-trigger-variables.png

 

11-Compose-GetItems.png

 

12-Condition-Actions.png

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

Hi Rob.

 

Got one thing not working now, it's basically when ever I'm trying to find a specific column it's not doing it.

 

It works if the column is called 'Title' or 'Column' but never when I'm looking for one I've actually named in a list.

 

So in this list there's a column called National insurance in which it'll have the person's national insurance number.

 

So the query I'm using is as below but whenever I run it it just says 'A column called National insurance doesn't exist even though it does. Please help!

Annotation 2020-01-14 144800.png

 

@RobElliott 

 

This is the exact response I'm getting when running it, I've replaced the actual NI number with ***********
 
{
"status": 400,
"message": "The expression \"NI number eq '***********'\" is not valid.\r\nclientRequestId: 40d55426-a22d-45fe-b6ac-6ca8df3bb3f1\r\nserviceRequestId: 40d55426-a22d-45fe-b6ac-6ca8df3bb3f1"
}
 

@deankingdk it's because you have a space in the column name in the SharePoint list. The flow strips it out so in the left hand part of the filter query remove the space and it should work fine. In the example below the SharePoint column is NI Number but the flow only works if the filterquery is NINumber:

99-filterQuery-Space.png

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks. 

GuyBoswell
Helper IV
Helper IV

Hi All,

In pretty much any other system I have learnt if you want a to increase by b you say

a=a+b

Or maybe more formally

set a=a+b

Or occasionally something really funky like

set a=add(a,b)

But in Power Automate it seems it is much more complicated.

I have seen the various work arounds using compose etc, I am not asking how to add a to b.

I am asking why is it so complicated?  Can anybody explain in words of one syllable?

I feel like I am missing something really fundamental about how Power Automate works and if I could get my head round it a lot of other things would be easier to understand.

Thank you for your help.

Guy

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (1,771)