Showing results for 
Search instead for 
Did you mean: 
Post Prodigy
Post Prodigy

Subtracting the value of a field in one list from the value of a field in another

Afternoon all


I have a list with an employees holiday allocation and another list where they request holidays. I have an approval workflow triggered on the second list and I'd like to take the number of days the employee is allocated and subtract the days they've requested (if approved) and tell them how many days they have.


The Flow as stands is below. What I tried to do was to put the allocation value in a Compose action, the days requested in another Xompose action, then use a third with this expression to do the maths: 



As soon as wrote the first Compose action Flow put it in a Apply to Each loop which I didn't think would be a problem and that's where I put the rest of the Compose actions. However it threw and error and wouldn't allow me to save the changes. 


Where am I going wrong? All help appreciated. 



Super User II
Super User II

Hi @darrenfloyd666 



1. For Second list, Use compose and take sum of all allocated leaves[approved]. you can use variable here so that all leaves store in a variable.(do not forget to use Append to variable)

2. For first list, Use Get Items - Get data from first list.

3. Use condition- Try to match employee code(or whatever is unique) between these list. When you do that it will take 'Apply to each' action automatically.

4. Once employee is matched then use another compose inside Apply to each to subtract second list leaves with first list leaves which we stored in a variable..




Impactful Individual
Impactful Individual

@darrenfloyd666 Looks like you're missing a comma between the two items.


It should be: sub(items('Apply_to_each')['Holiday_allocation'],triggerBody()['Days_requested']) 

Thanks @SamPo 


I set up two Compose actions earlier in the Flow and tried using them in the sub expression:


The error message I'm getting is:
Unable to process template language expressions in action 'Days_Remaining' inputs at line '1' and column '37741': 'The template language function 'sub' expects its first parameter to be an integer or a decimal number. The provided value is of type 'String'.
I'm guessing it's cause the output I'm getting is a string rather than a number? Do I need another Compose action to format the output so I can do the subtraction?

Sorry @SamPo realised that what I needed were just the number from the 'Holiday Allocation' field in the first list and the number from the 'Number of Days' Requested field in the second list. In the expression I'm finding the ' Number of Days' but I'm only getting the 'Body' and 'Value' values from the Get Items action from the first list. Any ideas how I get the 'Holiday Allocation' value from the first list to use in the expression.


All help welcome. 

Hi @darrenfloyd666 

Check your Get Item Action.  are you using any view under advance section in Get Item Action. Please provide image of your get item Action.




Helpful resources

MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,827)