Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula: select __ where Post Reply Post New Topic
Author Message
crstar
Newbie
Newbie


Joined: 02 Aug 2012
Online Status: Offline
Posts: 31
Quote crstar Replybullet Topic: Formula: select __ where
     Posted: 17 Oct 2012 at 4:06pm
I have 2 tables imported to crystal report, the linkage is as below:
 
tbl1.country = tbl2.country
tbl1.fran = tbl2.fran
tbl1.imp = tbl2.imp
 
The report allow user to enter country as parameter.
It group by country, fran, and imp to get field value:
 
tbl1.target, tbl2.sales
 
The problem I encounter is, if user enter parameter country = All, i need sum the tbl2.sales, this i manage to do.
 
But for tbl1.target, if user select "All" country, i need to select target WHERE tbl1.country='999', not sum.
 
The problem now is tbl2.country has 149,658,667.
While tbl1.country has 999,149,658,667
 
If all, tbl1.country = 999 while  tbl2 sum sales for all country 149,658,667
My report selection formula now is:
 
if {?Country}="All" then
({tbl1.country} = '149' or  {tbl1.country} = '658' or {tbl1.country} = '667') else
{tbl1.country} = {?country}
 
Any expert know how to select tbl1.target where tbl1.country='999' if user enter parameter "All"?
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 18 Oct 2012 at 4:47am
if {?Country} = "all" then
  true
else
 {tbl1.country} = {?Country}
 
since the result of this is just true or false, return true for all entries for the all, otherwise make them match...it's a confusing example as the vaules for tbl1 are the same as tbl2, with the addition of 999
 
HTH
IP IP Logged
crstar
Newbie
Newbie


Joined: 02 Aug 2012
Online Status: Offline
Posts: 31
Quote crstar Replybullet Posted: 18 Oct 2012 at 6:10pm
thanks for your reply. the problem is if user select ALL, i need to get the value from tbl1 where country=999, and value from tbl2 where sum all the data 149,658,667..
 
the database design a bit tricky..
 
 


Edited by crstar - 18 Oct 2012 at 6:10pm
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