Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Error- Must Be A Group That Matches This Field Post Reply Post New Topic
Author Message
rcoxe
Newbie
Newbie


Joined: 19 Apr 2018
Location: United States
Online Status: Offline
Posts: 10
Quote rcoxe Replybullet Topic: Error- Must Be A Group That Matches This Field
    Posted: 14 Apr 2021 at 10:28am
I have a report that shows me transactions and it is grouped by the document date (field is called DocDate). In the group options I have it set to sort by month. I am trying to create a formula that gives me an average amount per device. My formula is basically:

SUM({Amount},{DocDate})/SUM({Devices},{DocDate})

I get the error that there must be a group that matches the DocDate field. When I change the sort option to sort by day I do not get the error. How can I modify my formula to avoid this error?

Thanks for the help.

Edited by rcoxe - 14 Apr 2021 at 10:33am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 15 Apr 2021 at 6:40am
my first thought is create a formula that returns the month/year and then use that as your grouping.

something simple like:
totext(month({DocDate}), 0, "") + "/" + totext(year({DocDate}), 0, "")

Then in the grouping criteria, select your formula.
At least this is how I would try to get around the error.

While you are sorting by month, the grouping field is a date...I am thinking that Crystal is getting confused.

HTH
IP IP Logged
rcoxe
Newbie
Newbie


Joined: 19 Apr 2018
Location: United States
Online Status: Offline
Posts: 10
Quote rcoxe Replybullet Posted: 15 Apr 2021 at 6:54am
That what I was thinking had to be done. Thanks for confirming.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 29 Apr 2021 at 8:02am
Another way to do this would be to use a summary condition as the third parameter to the Sum() function. This would let you tell it to sum "for each month" instead of for each day, which is the default. So the formula would look something like:

SUM({Amount},{DocDate},"monthly")/SUM({Devices},{DocDate}, "monthly")

-Dell
IP IP Logged
rcoxe
Newbie
Newbie


Joined: 19 Apr 2018
Location: United States
Online Status: Offline
Posts: 10
Quote rcoxe Replybullet Posted: 30 Apr 2021 at 2:20am
Thanks hilfy, that's perfect.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.