Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Dynamic grouping by parameters Post Reply Post New Topic
Author Message
karthikkjm
Newbie
Newbie
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 21
Quote karthikkjm Replybullet Topic: Dynamic grouping by parameters
     Posted: 09 Jan 2012 at 5:22pm
in the report data source, i have one datatable, it contains the columns like
Invoice No, invoice Date, customer name, amount.

in this report user can select the report grouping by invoice date orĀ  by customer name. when i am creating a formula like this,

if(?GroupSelection) = 'Customer' then
{Invoice.Customer}
else if(?GroupSelection) = 'Date' then
{Invoice.Date}


it shows exception like, "expecting string"... because {Invoice.Date} is a column of DateTime, but {Invoice.Customer} is a column of string type.

Please help me how to create a single report with dynamic grouping...

Thanks in advance.


karthik
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Jan 2012 at 6:38am
if(?GroupSelection) = 'Customer' then
{Invoice.Customer}
else if(?GroupSelection) = 'Date' then
totext({Invoice.Date},"yyyy-MM-dd")

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Jan 2012 at 6:40am
this won't help you with the sorting on a string that was a date. Removes the option of grouping by different by date type options.
IP IP Logged
karthikkjm
Newbie
Newbie
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 21
Quote karthikkjm Replybullet Posted: 10 Jan 2012 at 8:11pm
thank you.
is any way to handle this ?
karthik
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 11 Jan 2012 at 4:01am
one way is to create 2 formulas
//Group1
if(?GroupSelection) = 'Customer' then {Invoice.Customer} else "n/a"
//GRoup2
if(?GroupSelection) = 'Date' then {Invoice.Date} else Date(0,0,0)

Group first on @group1

Group second on @group2
Conditionally suppress each group header based on the param value
IP IP Logged
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