@Dulat
To achieve this, you can try to use the Distinct function in PowerApps, which should return a one-column table that consists of distinct values from the specified column of the source table.
So, you can try and solve your issue as follows:
1. First, navigate to the screen where your Gallery control is, in your Power Apps Canvas App.
2. Now, in the Items property of the Gallery, instead of directly linking it to your SharePoint list, you can use the Distinct function. Assuming your SharePoint list is named MyList, you can use a formula like this:
Distinct(MyList, {ItemCode: ItemCode, Description: Description})
This should give you a gallery of unique ItemCode - Description pairs.
To add new items to the SharePoint list, make sure to implement logic in your app to check whether the combination of ItemCode and Description is already present in the list before adding. This can be done using the LookUp function:
If(IsBlank(LookUp(MyList, ItemCode = TextInput1.Text && Description = TextInput2.Text)),
Patch(MyList, Defaults(MyList), {ItemCode: TextInput1.Text, Description: TextInput2.Text, Size: TextInput3.Text}),
Notify("This Item Code and Description pair already exists!", NotificationType.Warning)
)
In the above formula:
- TextInput1.Text, TextInput2.Text, and TextInput3.Text should be replaced by your actual text input control's names where you enter the new ItemCode, Description, and Size.
- Patch is used to add a new item to the list.
- LookUp checks if the ItemCode and Description pair already exists in the list.
- IsBlank checks if the LookUp function returned anything.
- If the pair does not exist, the new item gets added to the list.
- If the pair does exist, a notification gets displayed.
Remember to replace the names in the formulas in the above examples, with the actual names used in your app, such as your SharePoint list's name (your data source's actual name) and the actual names of your input text boxes in the Canvas App.
Hope it helps @Dulat