Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Using a Lookup to Increment a value not working

(0) ShareShare
ReportReport
Posted on by 24

I have a model driven app with a embedded canvas app.

The canvas app has one gallery showing existing records in a table called (AFP Payment Schedules) based on a Job Number.

The second gallery I'm using with a collection to enable the user to input information and then I patch that into the AFP Payment Schedules table.

What I'm having a problem with is I'm trying to get last ID number (AFP Number) from the AFP Payment Schedules table, based on the Job Number and then increment ID by one. The second gallery should then be automatically listing the new line of info to be entered with the next AFP number after what already exists. The code I'm trying is below, but what I get returned each time is a zero. 

The existing AFP number is 1 so I'm expecting my new line in gallery two to be a 2 as its incremented 1 by 1.

 

Set(LastTotalAFP_ScheduleLines, LookUp('AFP Payment Schedules', 'Job Number' = [@ModelDrivenFormIntegration].Item.'Job Number').'AFP Number');
Set(TotalAFP_ScheduleLines, LastTotalAFP_ScheduleLines +1);
 
The collection then incorporates 
 AFPNumber: TotalAFP_ScheduleLines,
 

Thanks in advance for any help on this

David

  • dgarrick Profile Picture
    24 on at
    Re: Using a Lookup to Increment a value not working

    That worked perfectly, thank you.

  • Verified answer
    v-jefferni Profile Picture
    on at
    Re: Using a Lookup to Increment a value not working

    Hi @dgarrick ,

     

    Please try this:

    Set(
     LastTotalAFP_ScheduleLines, 
     First(
     Sort(
     Filter(
     'AFP Payment Schedules', 
     'Job Number' = [@ModelDrivenFormIntegration].Item.'Job Number'
     ),
     'AFP Number', 
     SortOrder.Descending
     )
     ).'AFP Number'
    );
    Set(TotalAFP_ScheduleLines, LastTotalAFP_ScheduleLines +1);

     

    Best regards,

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,587 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard