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 Apps / Set next higher number
Power Apps
Answered

Set next higher number

(0) ShareShare
ReportReport
Posted on by 145

Hello,

 

i need set variable to first next higher number than actual variable. For example a collection contain rows 1,2,3,7,9.

 

If my actual variable is 3 i need set 7.

 

Im trying this code but it not working.

 

Set(varRowNumber,First(Filter(colWeightOut,RowNumberInRun>varRowNumber)))
 
Thank you very much
Jakub
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,417 Most Valuable Professional on at

    Hi @Flashback ,

    You will need to run this

    ForAll(
     Sequence(CountRows(YourCollection)),
     Collect(
     colNo,
     If(
     !(Value in YourCollection.FieldName),
     {Number: Value}
     )
     )
    )

    Then the number you want will be

    First(coNo).Number

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Verified answer
    timl Profile Picture
    37,283 Super User 2026 Season 2 on at

    Hi @Flashback 

    This is an interesting question because at first glance, it appears that your original formula should work. On closer inspection, I think you're just missing a reference to RowNumberInRun (First/Filter will return a single record rather than the actual value you're looking for). 

    So if @WarrenBelz's solution doesn't work, you might want to try this:

    Set(varRowNumber,
     First(Filter(colWeightOut,RowNumberInRun>varRowNumber)).RowNumberInRun
    )

     

  • vaubeee Profile Picture
    533 on at

    Hi @Flashback ! Another approach to this would be to generate an indexed array after your colWeightOut collection has been generated:

    ForAll(
     colWeightOut,
     Collect(
     col_index,
     {
     value: Value,
     index: CountRows(col_index)
     }
     )
    )

    and then where needed set a variable for the next index:

     

    Set(nextIndex,LookUp(col_index, value = rowNumber).index + 1)

    and get the value from that index:

    LookUp(col_index, index = nextIndex).value

     

    ------------------------------------------------------------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard