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 / Patch forall and Loook...
Power Apps
Unanswered

Patch forall and Loookup , Dataverse

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

 

I am  having a problem with patch and forall.

 

I have a gallery(item:collectionA) like following. 

 

pricetype

Item

(lookup Column)

price

qty

total

A

a-b

100

2

200

B

a-b

200

5

1000

 

 

I have a combobox “com_pricetype” on my screen.

I would like to change “price” and “total” on my collection when I change “com_pricetype”.

 

When select pricetype “A” with my  “com_pricetype”, I would like to change like following.

Price is included on my item table.

pricetype

Item

(lookup Column)

price

qty

total

A

a-b

100

2

200

A

a-b

100

5

500

 

 

Somebody tell me how to do this.

Thanks,

Categories:
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    In order to better help you solve the problem, please provide more information.

     

    Could you tell me:

    Do you want to modify multiple pieces of data in the collection at once or the data in the dataverse?

    What is your purpose? Sorry, it’s hard for me to figure out your needs with these two examples.

    Does Item (lookup Column) play a role in your needs? 

     

    Best Regards,
    Wearsky

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

     

    @v-xiaochen-msft 

     

    Thank you for your help!


    Do you want to modify multiple pieces of data in the collection at once or the data in the dataverse?

    Yes, my item table is like following data.

     

    itemcode

    pricetypeA

    pricetypeB

    a-a

    50

    10

    a-b

    100

    200

     

    This is my collection table (before chainging data.)

    colle_order

    pricetype

    Item

    (lookup Column)

    price

    qty

    total

    A

    a-b

    100

    2

    200

    B

    a-b

    200

    5

    1000

     

    I want to change price and total (price*qty)  all at once to price with column pricetypeA. 

     

    pricetype

    Item

    (lookup Column)

    price

    qty

    total

    A

    a-b

    100

    2

    200

    A

    a-b

    100

    5

    500


    Did i make myself clear?

    I'm sorry if I may have been unclear.

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    I am still confused about your question. I assumed a collection and tested it.

    1\ Add a button control and set its Onselect property to:

    ClearCollect(TestCollection,{pricetype:"A",price:100,qty:2,total:200},{pricetype:"B",price:200,qty:5,total:1000})

    v-xiaochen-msft_0-1618451665211.png

     

    2\ Add a combo box control and set its Items property to:

    TestCollection.pricetype

     

    3\ Add another gallery control and set its Items property to:

    RenameColumns(DropColumns(AddColumns(AddColumns(TestCollection,"price2",LookUp(TestCollection,pricetype=ComboBox1.Selected.pricetype).price),"total2",price2*qty),"price","total"),"price2","price","total2","total")

     

    4\ The result is as follows:

    v-xiaochen-msft_1-1618451728898.png

    v-xiaochen-msft_2-1618451740397.png

     

    Is this your requirement?

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-xiaochen-msft 

    thank you for your help!

    Is it possible not to add a column but to patch (update)?

     

    AddColumns(TestCollection,"price2",LookUp(TestCollection,pricetype=ComboBox1.Selected.pricetype).price),


    My gallery is like a editable excel so I do not want to make a new column but to change data in my column.
    I would like to try this but just want to know if there is a way to do with patch.

     

    DropColumns(AddColumns(AddColumns(

     

     

    Thank you for your help!

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    1\ Add a button control and set its onselect property to:

    ClearCollect(TestCollection,{pricetype:"A",price:100,qty:2,total:200},{pricetype:"B",price:200,qty:5,total:1000})

     

    2\ Add a gallery control and set its Items property to:

    TestCollection

     

    3\ Add a combo box control 'ComboBox1' and set its Items property to:

    TestCollection.pricetype

     

    Set the combo box control's Onchange property to:

    ForAll(Sequence(CountRows(TestCollection)),If(Last(FirstN(TestCollection,ThisRecord.Value)).pricetype<>ComboBox1.Selected.pricetype,Patch(TestCollection,Last(FirstN(TestCollection,ThisRecord.Value)),{price:LookUp(TestCollection,pricetype=ComboBox1.Selected.pricetype).price});Patch(TestCollection,Last(FirstN(TestCollection,ThisRecord.Value)),{total:Last(FirstN(TestCollection,ThisRecord.Value)).price*Last(FirstN(TestCollection,ThisRecord.Value)).qty})))

     

    4\ The result is as follows:

    AAA.gif

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @v-xiaochen-msft 


    Thank you for your help.
    I'm very sorry for my poor explanation.
    I tried it and the prices were updated in bulk,

    but I wanted to change the prices in bulk based on the codes like "a-a" and "a-b" in the Item table.

    I also have this code in the table to be updated "colle_order", but the data type the column is Lookup.
    I am sorry, but could you please help me again?

     

    I've tried like this for the fist step but not working. 

     

    If(Drop_price_type_10.Selected.Value = "A",
    ForAll(colle_order
     ,
     Patch(colle_order,
     ThisRecord,
     {cr9d1_price:
     LookUp(item,product_code=ThisRecord._product_code).pricetypeA})
     )
    ,Drop_price_type_10.Selected.Value = "B",
    ForAll(colle_order
     ,
     Patch(colle_order,
     ThisRecord,
     {cr9d1_price:
     LookUp(item,product_code=ThisRecord._product_code).pricetypeB})
     )
    )

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard