Grouping by Month in Reports

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bandtank
    Active Community Member
    • Mar 2017
    • 408

    #1

    Grouping by Month in Reports

    EspoCRM allows report results to be grouped using various date functions. Grouping by month is possible, but a custom formula must be used. Grouping by month usually means:

    Code:
    Month Count
    01    8
    02    7
    ...
    One of the options in the GROUP field is MONTH: (...). The results may not be what one might expect:
    Code:
    Month   Count
    2024-01 4
    2024-02 3
    ...
    2025-01 4
    2025-02 4
    ...
    EspoCRM groups records using the following SQL when MONTH is selected:
    Code:
    GROUP BY
      DATE_FORMAT(performanceReport.date_start, '%Y-%m');
    instead of
    Code:
    GROUP BY
      DATE_FORMAT(performanceReport.date_start, '%m');​
    The good news is support provided a solution that works well. In the GROUP field in a report, use the following code to group by month:
    Code:
    MAP:(MONTH_NUMBER:(dateStart),
      1, '01',
      2, '02',
      3, '03',
      4, '04',
      5, '05',
      6, '06',
      7, '07',
      8, '08',
      9, '09',
      10, '10',
      11, '11',
      12, '12'
    )​
    Like this:

    Click image for larger version  Name:	image.png Views:	0 Size:	21.5 KB ID:	121705

    Here is a screenshot of the rest of the parameters:
    Click image for larger version  Name:	image.png Views:	0 Size:	42.6 KB ID:	121706

    Here are the results:
    Click image for larger version  Name:	image.png Views:	0 Size:	128.8 KB ID:	121707​​​
    Last edited by bandtank; Yesterday, 02:34 PM.
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9418

    #2
    Thanks for sharing. Worth noting that this is achievable for non-developer users too.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • bandtank
      Active Community Member
      • Mar 2017
      • 408

      #3
      Good point. Is there a tutorial forum for non-developer users? I didn't see one, but maybe I missed it. If so, i will post it there as well.

      Comment


      • yuri
        yuri commented
        Editing a comment
        There's no such.
    Working...