Reports - Group By not working properly

If I create a report and choose ‘groupBy’ it is hit or miss if it works properly.

My Product Line is the field and as you can see it doubles up on two of them.

I checked the database (Distinct) on my fields to ensure that there are only 4 types (Product Line)

I get various results but the one below is most consistent:

Version 7.11.12

Any ideas?

database

The problem was with two entries in the DB. The currency ID field was blank for some reason. Once i changed them to NULL the problem solved itself.

So ‘groupBy’ does not ‘groupBy’ one field but by many fields?!?!? I choose ‘groupBy’ ProductLine NOT by currency?!?!

Strange.

You’d have to check the actual DB queries that the Reports module is producing, these should appear in your logs if you’re set to debug level.

What file generates these Queries?

I don’t know, but I can try helping you find out if you give me a sample query, along with the Report that generates it.

Thank you for the offer. I think I got it sorted.

Hello johnwreford.
I’m also facing same issue. can you plz explain how you solved this?

Hi everyone,

I had the same issue with Group By not working properly in reports — records with the same group value were showing as separate rows instead of collapsing.

After investigating, I found the root cause: some records had the currency_id field blank or NULL in the database, while others had it set to -99 (system default currency). Since SuiteCRM internally includes currency_id in the GROUP BY clause when a currency field is part of the report, records with different currency_id values are treated as separate groups even if all other fields match.

The fix was straightforward:

  1. Update all records to have a consistent currency_id value:

UPDATE your_module
SET currency_id = ‘-99’
WHERE deleted = 0
AND (currency_id IS NULL OR currency_id = ‘’);

  1. When setting up the report, make sure to specify the currency you want to use in the report fields — this ensures the GROUP BY works consistently.

After applying this fix, the grouping and SUM worked correctly with one row per group as expected.

Hope this helps someone else!

Hello Javer,

thanks, nice findings.

There are some other issues around group by reporting features:

But those only sound similar.
Have you been able to reproduce this issue?
That sounds a bit like you had first entered data, then added a currency, then entered more data and tried to report then?
Which version do you use and is it an upgraded one?

Hi Bastian!

1. Group by Date (Y-M) not working
I tested this on SuiteCRM 8.9.1 and 8.9.2 and it works fine on my end. My suggestion is to check the Dropdown Editor and make sure the date format dropdown list has the correct values set internally sometimes the key/value pairs get misconfigured. See the attached screenshot for reference on how it should look.

2. Total count not working on Calls report
This is likely happening because you’re using the Status field twice in the same report. From my experience, that causes the summation to break. Instead, try setting the count/total on the ID field that works reliably for me. I’ve attached a screenshot showing my setup.

Hope that helps. Let me know how it goes.