Hi all,
I have a problem to add a column to a collection containing a CountRows from another collection.
There are two collections:
colOrders
ClearCollect(
colOrders,
Sort(
Distinct(
Orders,
OrderNumber
),
ThisRecord.Result,
Ascending
)
);
This results in a collection like:
Result:
2022-123
2022-124
2022-125
colOrderDetails
ClearCollect(
colOrderDetails,
OrderDetails
);
This results in a collection like:
OrderNumber | OrderDetail |
2022-123 | Order detail 1 |
2022-123 | Order detail 2 |
2022-124 | Order detail 3 |
2020-125 | Order detail 4 |
I want to add a new column "Counter" to colOrders which counts the number of order details, so in this example it should look like:
Result | Counter |
2022-123 | 2 |
2022-124 | 1 |
2022-125 | 1 |
I already tried the following code:
ClearCollect(
tempOrders,
colOrders,
AddColumns(
colOrderss,
"Counter",
0)
);
ForAll(
tempEnvironments,
Counter = CountRows(
Filter(
colOrderDetails,
ThisRecord.OrderNumber = Result
)
)
)
But even in the first ClearCollect, the column is added but without any value.
Also in the ForAll statement, it doesn't work.
Any idea woul be appreciated.
Best
Stefan
Solved! Go to Solution.
HI,
this works:
ClearCollect(
tempOrders,
AddColumns(
GroupBy(
OrderDetails,
"Ordernumber",
"Orderdetails"
),
"Counter",
CountRows(ThisRecord.Orderdetails)
)
)
Hi @stefansc ,
Try this
ClearCollect(
tempOrders,
AddColumns(
GroupBy(
"OrderNumber",
"Data"
),
"Counter",
CountRows(Data)
)
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Visit my blog Practical Power Apps
HI,
this works:
ClearCollect(
tempOrders,
AddColumns(
GroupBy(
OrderDetails,
"Ordernumber",
"Orderdetails"
),
"Counter",
CountRows(ThisRecord.Orderdetails)
)
)
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
187 | |
53 | |
52 | |
38 | |
37 |
User | Count |
---|---|
282 | |
97 | |
86 | |
80 | |
77 |