I have a collection (groupedData) that groups and count identical items, and another collection (Colors) with color values. I never know how many items the groupedData collection will have, so depending how many rows it has it'll need to pick just the needed items from the Color collection, and add it as a new column:
ClearCollect(
groupedData,
SortByColumns(
DropColumns(
AddColumns(
GroupBy(
AddColumns(
Filter(
'Catalog',
Year = ReviewYear
),
"RO",
'Regional Office'.Value
),
"RO",
"GroupedItems"
),
"Count Value",
CountRows(GroupedItems)
),
"GroupedItems"
),
"RO",
Ascending
)
);
Colors Collection:
ClearCollect(
Colors,
["#FF6633", "#FFB399", "#FF33FF", "#FFFF99", "#00B3E6",
"#E6B333", "#3366E6", "#999966", "#99FF99", "#B34D4D",
"#80B300", "#809900", "#E6B3B3", "#6680B3", "#66991A",
"#FF99E6", "#CCFF1A", "#FF1A66", "#E6331A", "#33FFCC",
"#66994D", "#B366CC", "#4D8000", "#B33300", "#CC80CC",
"#66664D", "#991AFF", "#E666FF", "#4DB3FF", "#1AB399",
"#E666B3", "#33991A", "#CC9999", "#B3B31A", "#00E680",
"#4D8066", "#809980", "#E6FF80", "#1AFF33", "#999933",
"#FF3380", "#CCCC00", "#66E64D", "#4D80CC", "#9900B3",
"#E64D66", "#4DB380", "#FF4D4D", "#99E6E6", "#6666FF"]
);
How can achieve this?
Thanks in advance.
Solved! Go to Solution.
Hi @emfuentes27 ,
This blog of mine should assist you here. The below should give you an idea on structure, but note free-typed, so watch commas/brackets
With(
{
wColourNo:
FirstN(
Colors,
CountRows(groupedData)
)
},
With(
{
wGrouped:
ForAll(
Sequence(
CountRows(groupedData)
),
Patch(
Last(
FirstN(
groupedData,
Value
)
),
{RowNo1: Value}
)
),
wColors:
ForAll(
Sequence(
CountRows(wColourNo)
),
Patch(
Last(
FirstN(
wColourNo,
Value
)
),
{RowNo2: Value}
)
)
},
ClearCollect(
colGroupedColors,
AddColumns(
wGrouped,
"GroupColor",
LookUp(
wColors,
RowNo2 = RowNo1
).Value
)
)
)
)
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 @emfuentes27 ,
This blog of mine should assist you here. The below should give you an idea on structure, but note free-typed, so watch commas/brackets
With(
{
wColourNo:
FirstN(
Colors,
CountRows(groupedData)
)
},
With(
{
wGrouped:
ForAll(
Sequence(
CountRows(groupedData)
),
Patch(
Last(
FirstN(
groupedData,
Value
)
),
{RowNo1: Value}
)
),
wColors:
ForAll(
Sequence(
CountRows(wColourNo)
),
Patch(
Last(
FirstN(
wColourNo,
Value
)
),
{RowNo2: Value}
)
)
},
ClearCollect(
colGroupedColors,
AddColumns(
wGrouped,
"GroupColor",
LookUp(
wColors,
RowNo2 = RowNo1
).Value
)
)
)
)
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
User | Count |
---|---|
124 | |
87 | |
86 | |
75 | |
69 |
User | Count |
---|---|
214 | |
181 | |
140 | |
97 | |
83 |