Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AleUP
Regular Visitor

Groupby function error

Hello Everybody,

 

i'm new in this forum but I always found your Q&A very usefull for my job.

I'm dealing with this issue since a while, but I was not able to find a solution so I hope you will help me.

I don't understand an error that appear when I try to "group by" my dataset.

The error say "expression.Error: not possible to apply operator - to type text and text", but the group by function is done without appling any mathematical operation, is just a step I need to perform in order to have the "index" column by group.

Here below the error (it is in italian, sorry  for that)

AleUP_0-1639491728448.png

and here below the advance editor text (since the step before "group by" everithing works well)

AleUP_1-1639491983849.png

and the data structure before the error

AleUP_0-1639492457269.png

 

I already tried to change the type of the columns but nothing change.

 

I'm depress since the same code works fine with a "smaller data set".

 

Thanks all who would help me.

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @AleUP 

 

How did you use the Groupby function? You wrote the M code directly or used the Group By feature in User Interface? 

 

I like to use the User Interface to do group by. According to your code, you can select All Rows in Operation box. 

21121704.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Hi @v-jingzhang ,

yes I used the User Interface to do group by and selected All Rows in Operation box as you did.

HotChilli
Super User
Super User

I suppose there is a suspicion that there is a text value in a column which is marked as numeric.  It probably only shows as a problem once more than 1000 rows are loaded.

You could experiment by simplifying the steps in the query/ making all fields text type then doing the Group by OR loading all rows in the preview and using the 'column quality'/distribution/profile features from the View menu

Thanks  for your reply, i'm tring to do as you suggested, but it doesn't work: I add the step to modify all columns type to text

AleUP_0-1639557478345.png

AleUP_1-1639557550248.png

I don't understand wich "operation" it need to perform in this step??? Why the error reports "operator - "??

 

Yesterday I noticed that if I delete the step "sort columns", as per magic the group by works without any error.

 

AleUP_0-1639554524246.png

 However I need To perform this step to order the columns before the grouping because is important to assign the index correctly

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.