Hi guys,
I am attempting to build a parts catalog, with in the app i would like to add a part to a data table then return the number of times that part is added into a single row with the number of time the part was added.
The formula i am currently using is this:
Collect(DataTable2, {NO:'S-#', PARTCODE : Product, QTY : inCart +1, DESCRIPTION : Description, MATERIAL : None}); Set(inCart, CountIf(DataTable2, PARTCODE = ThisItem.Product))
However, I am having issues removing repeddative rows and getting the QTY correct.
Thanks in advance for the help!
Solved! Go to Solution.
Hi @Jagarrison1 ,
Have you taken a try with the above solution I provided?
If you want to remove repeated rows from your DataTable2, I think the solution I provided above could achieve your needs. Please take a try with the solution I provided above, then check if the issue is solved.
In addition, based on the needs that you mentioned, I suppose that you want to add 1 to the QTY column when you add same product into your DataTable2 rather than add a new row for the same Product, is it true?
If you just want to add 1 to the QTY column when you add same product into your DataTable2 rather than add a new row for the same Product, I think there is something issue with your formula.
I have made a test on my side, please take a try with the following workaround. Please modify your formula as below:
If(
!IsBlank(LookUp(DataTable2, PARTCODE = Product)), /* <-- Check if the DataTable2 collection has contained same Product record already */
Patch(DataTable2, LookUp(DataTable2, PARTCODE = Product), {QTY: QTY+1}),
Collect(DataTable2, {NO:'S-#', PARTCODE : Product, QTY : 1, DESCRIPTION : Description, MATERIAL : None})
);
Set(inCart, CountIf(DataTable2, PARTCODE = ThisItem.Product))
Please consider take a try with above solution, then check if the issue is solved. Then within your DataTable2, it would not contain repeated rows for same Product, and the Qty column would store correct value.
More details about the Patch function, please check the following article:
Best regards,
Hi @Jagarrison1 ,
Do you want to remove the repeated rows from the DataTable2 collection?
I assume that the PARTCODE Column is the Primary column in your DataTable2 collection, which could identify one record uniquely, is it true?
If you want to remove the repeated rows from the DataTable2 collection, please take a try with the following formula:
ForAll( RenameColumns(DataTable2, "PARTCODE", "PARTCODE1"),
If(
CountRows(Filter(DataTable2, PARTCODE = PARTCODE1)) > 1, /* <-- Check if current loop item has repeated items within the DataTable2 */
Remove(DataTable2, LookUp(DataTable2, PARTCODE = PARTCODE1))
) )
More details about the ForAll function in PowerApps, please check the following article:
Best regards,
Yes, I want to remove all repeated rows and return the number of times it was repeated into the "QTY" Column. Yes it is the primary column and it is unique.
Hi @Jagarrison1 ,
Have you taken a try with the above solution I provided?
If you want to remove repeated rows from your DataTable2, I think the solution I provided above could achieve your needs. Please take a try with the solution I provided above, then check if the issue is solved.
In addition, based on the needs that you mentioned, I suppose that you want to add 1 to the QTY column when you add same product into your DataTable2 rather than add a new row for the same Product, is it true?
If you just want to add 1 to the QTY column when you add same product into your DataTable2 rather than add a new row for the same Product, I think there is something issue with your formula.
I have made a test on my side, please take a try with the following workaround. Please modify your formula as below:
If(
!IsBlank(LookUp(DataTable2, PARTCODE = Product)), /* <-- Check if the DataTable2 collection has contained same Product record already */
Patch(DataTable2, LookUp(DataTable2, PARTCODE = Product), {QTY: QTY+1}),
Collect(DataTable2, {NO:'S-#', PARTCODE : Product, QTY : 1, DESCRIPTION : Description, MATERIAL : None})
);
Set(inCart, CountIf(DataTable2, PARTCODE = ThisItem.Product))
Please consider take a try with above solution, then check if the issue is solved. Then within your DataTable2, it would not contain repeated rows for same Product, and the Qty column would store correct value.
More details about the Patch function, please check the following article:
Best regards,
User | Count |
---|---|
137 | |
135 | |
78 | |
72 | |
69 |
User | Count |
---|---|
222 | |
137 | |
78 | |
60 | |
55 |