cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MihirY
Advocate IV
Advocate IV

How to do a group by with Choice field

I am having a choice field called Cateogry which is having values as "Sancks,Electronics, Books" etc. Now i want to group by these SharePoint list items with category and show on Pie chart as well as in Gallery. Earlier I have maitained in single line of text for cateogry field. Then i have used below formula. Since I have changed column data type from Single line of text to choice, this formula will not work. This is giving error at column name and saying, expected values are Text. how to deal with this? Is it an issue or limitation?

AddColumns(GroupBy('Purchase Orders',"Category", "Group"), "TotalQuantity", Coalesce(Sum(Group, Quantity),0))
1 ACCEPTED SOLUTION

Accepted Solutions

Workaround:
Use AddColumns to introduce a new field based on the Complex field then group by the new field.

e.g. if my choice field is Category 

 

Groupby(AddColumns(DataSourceName, "NewFieldName",Category.Value),"NewFieldName","GroupName")

View solution in original post

5 REPLIES 5
v-yamao-msft
Community Support
Community Support

Hi MihirY,

 

Thanks for feedback.

 

Per my test, I found that a Choice column type is not supported in the GroupBy function.

 

Please consider to submit a request at PowerApps ideas Forum:
https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

 

I will help and collect it on my side.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

It is sad to know that Choice field is not supported for GroupBy function. Any workaround is there? 

One workaround i think is:

We can create one more field in the same list with single line of text and update the value with workflow as choice field value. Now use that field in groupby function inside powerapp. But this is too indirective way. What you think?

I have submitted an idea in power apps form for Choice field not supported in groupby function.

Workaround:
Use AddColumns to introduce a new field based on the Complex field then group by the new field.

e.g. if my choice field is Category 

 

Groupby(AddColumns(DataSourceName, "NewFieldName",Category.Value),"NewFieldName","GroupName")

So far so good.

And How about to take count RiskStatus

 

GroupBy(
AddColumns(
RiskAndIssueLog,
"NewFieldName",
RiskStatus.Value
),
"NewFieldName",
"RiskName"
)

cindyredo
New Member

@gokello Can anyone help with taking this a step further. I've got the grouped by on a choice field working, as well as a count of those items. But I also need to SUM a couple of fields in the list (fields called Copies (numeric) and Impressions (numeric) and Total Impressions (calculated copies x impressions).

 

This works great:

SortByColumns(
GroupBy(AddColumns(Request,"OrgCodeGroup",'Org Code'.Value),"OrgCodeGroup","GroupedByOrgCode"),
"OrgCodeGroup",Ascending)

 

Thanks, any help would be greatly appreciated.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,510)