Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Power Apps: Error in Patch formula for updating quantity based on user input

(1) ShareShare
ReportReport
Posted on by 2

Hello everybody,

I’m building an app using Power Apps Studio, which is connected to a Microsoft List. The app was auto-generated, and I’ve made some modifications.

I’m trying to create a formula that allows me to update the quantity (Kolicina) of a specific item in the list based on an ID entered by the user. However, I keep running into issues, and I’d appreciate your help.

Here’s what I want to achieve:

  • A user enters an ID and a quantity to subtract.
  • The app finds the item with the corresponding ID in the list.
  • The app reduces the Kolicina field for that item by the entered quantity.

Here’s my formula:

Patch(
Offcut,
LookUp(Offcut, Ident = Value(Ident_DataCard2_1.Default)), // Find the item by ID
{ Kolicina: Kolicina - Value(Kolicina_DataCard2_1.Default) } // Update the quantity
)

Issues I’m facing:

  1. I sometimes get an error saying, "Incompatible types for comparison: text, number".
  2. Other times, I get an error like, "Invalid use of Text property", even though the controls seem to have the correct values.

Additional Details:

  • Offcut is the name of the list.
  • Ident is a column in the list (it’s supposed to be numeric).
  • Kolicina is a numeric column that stores the quantity.
  • Ident_DataCard2_1.Default is the user input for the ID.
  • Kolicina_DataCard2_1.Default is the user input for the quantity to subtract.

What I’ve tried:

  • Ensuring that Ident is numeric by using Value().
  • Using labels to display the values of Ident_DataCard2_1.Default and Kolicina_DataCard2_1.Default to debug.
  • Changing LookUp to directly match Ident without Value().

Questions:

  1. Is my formula structured correctly?
  2. How can I ensure compatibility between text and number types when comparing or updating values?
  3. Are there any debugging tips I can use to pinpoint where the issue is?

Any guidance would be greatly appreciated! 😊

Thank you in advance!

Categories:
  • NJ-17011247-0 Profile Picture
    NJ-17011247-0 2 on at
    Power Apps: Error in Patch formula for updating quantity based on user input
    @mmbr1606 Thank for your reply but this is not valid reply. 
     
    I still have a problem. 
  • mmbr1606 Profile Picture
    mmbr1606 10,429 on at
    Power Apps: Error in Patch formula for updating quantity based on user input
    hey
     
     
    can u try this:
    Patch(
        Offcut,
        LookUp(Offcut, Ident = Value(Ident_DataCard2_1.Text)),
        { Kolicina: LookUp(Offcut, Ident = Value(Ident_DataCard2_1.Text)).Kolicina - Value(Kolicina_DataCard2_1.Text) }
    )
    
    If it helped please mark as verified answer
     
     
    cheers

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,434

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,722

Leaderboard