web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Expression to Add Values
Power Automate
Answered

Expression to Add Values

(1) ShareShare
ReportReport
Posted on by 111

Hi everyone,

I'm working on a Power Automate flow where I need to add two integer values from trigger outputs and increment one of them by 1. However, I'm encountering an error, and I can't seem to figure out what's wrong. The error message I'm getting is:

 

 

InvalidTemplate
Unable to process template language expressions in action 'Initialize_variable_2' inputs at line '0' and column '0': 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.

 

 

 

azni_0-1720057024520.png

 

 

Here's the expression I'm using:

 

 

add(int(triggerOutputs()?['body/CARCount/Value']),add(int(triggerOutputs()?['body/OFICount/Value']),1))

 

 

I have tried adding coalesce to handle potential null values, but I still encounter the same issue:

 

 

add(coalesce(int(triggerOutputs()?['body/CARCount/Value']), 0),add(coalesce(int(triggerOutputs()?['body/OFICount/Value']), 0), 1))

 

 

The view of the whole flow:

(attached below as it shown bad resolution)

 

Hence, I would like to hear your opinion in this matter. Thank you!

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,429 Super User 2025 Season 2 on at

    Hi   

    Unfortunately you didn't share the actual values.

     

    This part is a great share

    add(int(triggerOutputs()?['body/CARCount/Value']),add(int(triggerOutputs()?['body/OFICount/Value']),1))

     

    Here is what I'd ask you to do

    Switch from New to Classic Mode

     

    Go to a run that failed

    Open it

    Look at the Inputs INTO the Initialize Variable 2, as we need to see what was put in.

     

    Also you coalesce wont do anything, because the error it with the INT function and coalesc happens after the INT occurs.

     

    Please take pictures of the Inputs and Outputs of Initialize Variable 2 in Previous Mode, not the new one.

     

    You can however, look at the Code View of the new one, and paste that too.


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn:
    https://www.linkedin.com/in/michaelgernaey

    @azni

  • azni Profile Picture
    111 on at

    Hi, @FLMike . 

     

    The code view of the Initialize variable 2:

     

    {
     "type": "InitializeVariable",
     "inputs": {
     "variables": [
     {
     "name": "varNCRcount",
     "type": "integer",
     "value": "@add(coalesce(int(triggerOutputs()?['body/CARCount/Value']), 0),add(coalesce(int(triggerOutputs()?['body/OFICount/Value']), 0),1))"
     }
     ]
     },
     "runAfter": {
     "Initialize_variable": [
     "Succeeded"
     ]
     },
     "metadata": {
     "operationMetadataId": "67be1fb3-0849-434e-998f-2e5e6795329d"
     }

     

     

    Thank you for highlighting this matter to me!


    Also you coalesce wont do anything, because the error it with the INT function and coalesc happens after the INT occurs.


    I hope these pictures are sufficient enough: 

    After run.pngOutput.pngflow bfr and aft.png

  • Michael E. Gernaey Profile Picture
    53,429 Super User 2025 Season 2 on at

    Hi @azni 

     

    let's do something super simple, its hard to read that stuff because it so small even at 500 zoom

     

    Please add 2 compose, because your Initialize Variables

     

    In the first one, in the expression put

     

    triggerOutputs()?['body/CARCount/Value']

     

     

    In the second put

     

    int(triggerOutputs()?['body/OFICount/Value']

     

     

    This will tell us which ones it thinks is empty

     

    Also do you have a Schema for the Data I ask because to make this WAY easier, would be to put a ParseJSON, using the triggerOutputs()?['body']

     

    And turn it all into Dynamic properties. 

     

    If you have a full sample schema we can do that, but before that please do the 2 composes for me.

    Thanks!

     

  • azni Profile Picture
    111 on at

    Hi @FLMike 

     

    I tried as you suggested.

     

    The second expression is invalid. Hence, I deleted int(

    image.png

     

    The result:

    Left: Inserted compose below the Initialize Variable therefore action is skipped

    Right: Inserted compose above Initialize Variable, it shows click to download but shows blank page when clicked

    screencapture-make-powerautomate-environments-Default-5a5d28b7-2b31-4397-b7b5-a3328b8f8d18-flows-shared-b6d1a9d0-ab48-499b-a121-903afff7a52a-2024-07-09-15_46_09.pngscreencapture-make-powerautomate-environments-Default-5a5d28b7-2b31-4397-b7b5-a3328b8f8d18-flows-shared-b6d1a9d0-ab48-499b-a121-903afff7a52a-2024-07-09-15_44_55.png

     

    Sadly, I do not have Schema for the Data as it keeps showing Invalid JSON.

  • Verified answer
    azni Profile Picture
    111 on at

    I have no idea what is going on, but this expression makes the flow work

     

    add(
     int(coalesce(triggerOutputs()?['body/CARCount/Value'], '0')), 
     add(
     int(coalesce(triggerOutputs()?['body/OFICount/Value'], '0')), 
     1
     )
    )

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard