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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
Community Champion
Community Champion

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.