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 / How to get next value ...
Power Automate
Answered

How to get next value in a list

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

hi,

 

I have a list that I am trying to calculate the difference between the values of current row and next row, but I am not sure how to get the next row value in a list.

 

I tried using:

For each CurrentItem in List

      If %List + 1% - CurrentItem = 1 Then

             Add item CurrentItem to AnotherList

      End

End

 

PowerAutomate Desktop doesnt prompt me an error on that but it also doesnt do anything to populate the AnotherList.

 

I thought about creating a 2nd list (lets call that List2) then remove List[0],  then loop the list like List[%LoopIndex + 1%] - List[%LoopIndex%], but it still wouldnt populate the AnotherList.....

 

and since PAD cannot create a new column in Excel, I cant just write those 2 list in 2 columns and do the math there either....

 

any thought on how can I do this?

I have the same question (0)
  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Anonymous 

    Try this flow (steps 1-2 may be different depending on how you get your list, here I simulated capturing values from an excel worksheet):

     

    1. ‘Launch Excel’ with the file you want to capture list
    2. ‘Read from Excel worksheet’ to capture the range of values. This gives you %ExcelData% as variable produced (the list to be worked)
    3. ‘Create new list’: name it %ResultList%
    4. 'Loop': Starts from = 0, End to = %ExcelData.RowsCount -2%, Increment by = 1. This gives %LoopIndex% as produced variable
    5. ‘Set variable’: %ExcelData[LoopIndex]%. Define %CurrentItem% as variable produced
    6. ‘Convert text to number’: Text to convert = %CurrentItem%. Define %CurrentItem% as variable produced
    7. ‘Set variable’: %ExcelData[LoopIndex+1]%. Define %NextItem% as variable produced
    8. ‘Convert text to number’: Text to convert = %NextItem%. Define %NextItem% as variable produced
    9. ‘Set variable’: %NextItem-CurrentItem%. Define %Result% as variable produced
    10. ‘If’ %Result% = 1 then
    11. ‘Add item to list’, Add item = %CurrentItem%, Into list = %ResultList%
    12. ‘End’ (of If conditional)
    13. ‘End’ (of Loop)

    This can be optimized, but worked fine in test.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    hi @Anonymous,

     

    thanks that works!

     

    I have another question about the syntax for the variables, do we only need to use %% when we define a new variable? I was confuse about when to use %% around a variable and I thought it is needed for every variable.... thats why in my OP I put something like %List[%LoopIndex%]% 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    According to PAD documentation Variable manipulation and the % notation - Power Automate | Microsoft Docs:

    yasunm02_0-1628306720916.png

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 481

#2
11manish Profile Picture

11manish 278

#3
David_MA Profile Picture

David_MA 276 Super User 2026 Season 1

Last 30 days Overall leaderboard