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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Increment variable wit...
Power Automate
Answered

Increment variable with conditions

(0) ShareShare
ReportReport
Posted on by 364 Moderator

How to incremente a variable with a condition?

 

I already use the  module. 

PierreCA_0-1710871774187.png

The code to test the value and its possible responses. 

 

if(equals(outputs('Obtenir_les_éléments_EvolutionStatutDemande')?['body/value'],'15'),0,1)

 

 The condition doesn't work, but I'don't know why. 

 

I've try with

 

 

if(equals(outputs('Obtenir_les_éléments_EvolutionStatutDemande')?['body/value']?['column_name'],'15'),0,1)

 

 

I'don't find real documentation on that use. 

 

 

Thanks

Categories:
I have the same question (0)
  • v-yetonggu-msft Profile Picture
    Microsoft Employee on at

    Hi  @PierreCA ,

    Increment variable please use it with 'Apply to each' loop.

    I did a test for your reference.

    In my scenario:

    My SharePoint:

    Please make sure the selected column is a single line text column.

    vyetonggumsft_0-1710909247558.png

    My Flow:

    vyetonggumsft_1-1710909272355.png

    vyetonggumsft_6-1710909102322.png

     

    if(equals(items('Apply_to_each')?['ColumnName'],'15'),0,1)

     

    Best Regards,

    Sunshine Gu

  • PierreCA Profile Picture
    364 Moderator on at

    Hello @v-yetonggu-msft , 

    My actual flow has an additionnal step in the Apply to each function.  The previous steps have been tested and they give the answer expected. 

     

    In Apply to Each, I create an array of values. 

    In the Apply to Each 2, I test one by one the values of the array against values contained in a second list. Then, I conditionnally increment  the variable varSommeDemandesActives. 

    That's why I write my code that way, but it doesn't work: 

    if(equals(outputs('Obtenir_les_éléments_EvolutionStatutDemande')?['body/value']?['column_name'],'15'),0,1)

    As the tested value is an ID number, I've try (with the real column name): 

    'column_name'

    and 

    'column_name:ID'




    PierreCA_0-1710937850934.png

     



  • Verified answer
    PierreCA Profile Picture
    364 Moderator on at

    The solution is to explicitely point the line of data into the body of the result provided by Get Items function. As I try to compare a foreign ID in a SharePoint list, I must specify that point too. 

     

    The right line of code is the following: 

    if(equals(outputs('Obtenir_les_éléments_EvolutionStatutDemande')?['body']?['value'][0]?['FK_idStatutDemande_x003a_ID']?['Id'],15),0,1)

     
    Source of inspiration: How to get a specific value from a JSON in Power Automate (tomriha.com)

    Thanks for your help @v-yetonggu-msft . 🙂

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 976

#2
Valantis Profile Picture

Valantis 863

#3
Haque Profile Picture

Haque 547

Last 30 days Overall leaderboard