How To Fetch Items From SharePoint List To PowerApps Gallery, Calculat

Introduction

In this article, I’m going to demonstrate how Sharepoint List Records are fetched to the PowerApps Gallery Control and, in the gallery we'll be calculating some values as per the requirement, then those calculated values will be updated again to the List.

STEP 1 - Creating a List

  • List Name: Calculation
  • ItemName: (Single Line Text)
  • Quantity: (Number)
  • UnitPrice:(Number)
  • Total:(Number)

Create the List as per the above specifications.

Enter some dummy values to the ItemName, Quantity, UnitPrice Columns.

STEP 2 - Working with Power Apps gallery

Go to PowerApps and create a blank canvas app and name it as per the Project Title.

Add a blank vertical Gallery to the Screen and you can rename it as per your need.

Add the Data Source from the SharePoint List to The Gallery Items.

Select the Gallery control and choose the pencil icon to edit the require fields with context to List Data Source.

Put some Controls and change their properties as follows,

  • Put a Label Control- Set Text Property-ThisItem.ItemName
  • Put a Label Control- Set Text Property-ThisItem.Quantity
  • Put a Label Control- Set Text property-ThisItem.UnitPrice
  • Put a Text Input Control- Set Default Property:ThisItem.Quantity*ThisItem.UnitPrice

STEP 3 - Function To Update List Items

Add a Button Control to the Screen and rename it as you need.

Write the  following functions on button On Select Property,

ForAll(RenameColumns(Gallery1.AllItems, "ID", "CID"), Patch(Calculation, LookUp(Calculation, ID = CID), {
    ItemName: lblName.Text,
    Quantity: Value(lblQty.Text),
    UnitPrice: Value(lblUP.Text),
    Total: Value(txtTotal.Text)
}));

STEP 4 - Save & Run the Application

Save the Application and run it. The Application runs successfully and will update all the Calculated items from the Gallery to the Share Point List you are working with.

STEP 5 - Checking The List Data Source

Go to Your Share Point List and refresh it. You will see that all the Total columns are updated.

Conclusion

In the above article we successfully did the calculation and updating of calculated Values to the SharePoint List as per the requirements.