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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,244)