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 Apps / Conditional Increments
Power Apps
Unanswered

Conditional Increments

(0) ShareShare
ReportReport
Posted on by 36

I created a simple PowerApps applications (with some tips from the awesome people in this forum) and management loves it.


They have asked for an enhancement that I am seeking some help with. 

 

Here's what the table looks like:

 

powerAppsTable_01.jpg

 

This is the data entry screen: 

 

powerAppsTable_02.jpg

 

What we would like to do is for the revision number default as 1 unless the JOB Number and Department equal to a past entry and then if so, increment the revision number by one.

 

Any suggestions on how to code this?

Thanks...

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    on at

    You can use the LookUp() function to search the table for the Job# and Department and return the revision #, then increment it. If no record is found, default it to 1.

    ---
    If this answered your question, please click "Accept Solution". If this helped, please Thumbs Up.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Set the text property of the Textbox control to If(!IsBlank(Lookup(Table1, revision = ThisItem.revision)), ThisItem.revision +1, 1)
    Set the display mode of the card containing the textbox control to Disabled to prevent the user from changing it.

  • v-bofeng-msft Profile Picture
    on at

    Hi @Garak0410 :

    Could you tell me:

    Is the form on the second picture you show a new form or an edit form?

    What is Revision's data type?

    I assume it is a new form(DefaultMode:FormMode.New),and Revision is a number filed.

    Please try this solution:

    set the textinput control(Revision#)'s Default property to:

     

    If(
     IsBlank(
     Lookup(yourdatasource,
     'JOB #'=textinputJOB#.Text && Dept=textinputDept.Text /*textinputJOB# and textinputDept are textinput controls*/
     )
     ), /*If the specified record cannot be found, the Revision is 1*/
     1,
     Lookup(Sort(yourdatasource,Revision,Descending),
     'JOB #'=textinputJOB#.Text && Dept=textinputDept.Text
     ).Revision+1 /*Find the value of the largest revision in the records that meet the conditions*/
    )

     

     Best Regards,

    Bof

  • Brian Wolters Profile Picture
    36 on at

    That screen shot was from a NEW entry form. 

     

    The back end is an excel spreadsheet on OneDrive, and that column is set as GENERAL. 

  • Community Power Platform Member Profile Picture
    on at

    You could add a column to your spreadsheet called "NextRevision" and set the value as

    =[@Revision]+1

     Then, in PowerApps you can reference that column. If it's a new entry entirely, then you can default it to 1.

  • v-bofeng-msft Profile Picture
    on at

    Hi @Garak0410 :

    Please try this code:

    If(
     IsBlank(
     Lookup(yourdatasource,
     'JOB #'=textinputJOB#.Text && Dept=textinputDept.Text /*textinputJOB# and textinputDept are textinput controls*/
     )
     ), /*If the specified record cannot be found, the Revision is 1*/
     1,
     Value(Lookup(Sort(yourdatasource,Revision,Descending),
     'JOB #'=textinputJOB#.Text && Dept=textinputDept.Text
     ).Revision)+1 /*Find the value of the largest revision in the records that meet the conditions*/
    )

    Best Regards,

    Bof

  • Brian Wolters Profile Picture
    36 on at

    @v-bofeng-msft wrote:

    Hi @Garak0410 :

    Please try this code:

     

    If(
     IsBlank(
     Lookup(yourdatasource,
     'JOB #'=textinputJOB#.Text && Dept=textinputDept.Text /*textinputJOB# and textinputDept are textinput controls*/
     )
     ), /*If the specified record cannot be found, the Revision is 1*/
     1,
     Value(Lookup(Sort(yourdatasource,Revision,Descending),
     'JOB #'=textinputJOB#.Text && Dept=textinputDept.Text
     ).Revision)+1 /*Find the value of the largest revision in the records that meet the conditions*/
    )

     

    Best Regards,

    Bof


    Quick question...it doesn't seem to like this section of code...any suggestion on what to look for here?

     

    revision_PowerApp_02.jpg

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Garak0410 

    If your Job# is unique then the part of the filter for dept is unnecessary.  If it is a number type column in your list then you need to wrap the textinputJOB#.Text in Value() ie. Value(textinputJOB#.Text)

  • Brian Wolters Profile Picture
    36 on at

    @Drrickryp wrote:

    Hi @Garak0410 

    If your Job# is unique then the part of the filter for dept is unnecessary.  If it is a number type column in your list then you need to wrap the textinputJOB#.Text in Value() ie. Value(textinputJOB#.Text)


    The job number is unique however, we may make several revisions to that job number for the same department (Drafting, Trim, Estimating, etc.), so it does need to check both Department and Job to see if they have an existing entry and then make it Revision 2, 3, 4, etc.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Garak0410 

    Does your list have an ID that doesn't change even if the Job# is modified?  Please see my blog post for why this is important. https://powerusers.microsoft.com/t5/News-Announcements/Relational-Database-Principles-and-PowerApps-Step-3-Keys-and/ba-p/188640 

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 Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard