Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Select Expert - results changing Post Reply Post New Topic
Author Message
GregF
Newbie
Newbie
Avatar

Joined: 04 May 2018
Location: United States
Online Status: Offline
Posts: 3
Quote GregF Replybullet Topic: Select Expert - results changing
    Posted: 07 May 2018 at 8:54am
I am running into a problem =- where my select expert changes based on which part of the query I bring to the top. I do have several dynamic parms which bring back fairly large list of items to select from (3 pages).   Then I base the query off what the user selects in those and other parms.

Here is they query

if {?Client}<>"*ALLCLIENTS" then {Client.DISPLAY_NAME}={?Client} else true and
if {?Location}<>"*ALLLOCATIONS" then {Location.DISPLAY_NAME}={?Location} else true and
if {?Impact Type}<>"*ALLIMPACTS" then {CVGCPLIMPACTM1.TYPE} = {?Impact Type} else true and
if {?Ticket Type}="Change" then {CVGCPLIMPACTM1.NUMBER} startswith "C"
else if {?Ticket Type}="Incident" then {CVGCPLIMPACTM1.NUMBER} startswith "IM"
else if {?Ticket Type}="Problem" then {CVGCPLIMPACTM1.NUMBER} startswith "PM"
else true and
if {?Program}<>"*ALLPROGRAMSS" then {Program.DISPLAY_NAME}={?Program} else true and
date({@relevant_date}) in {?DateRange} and
not {@nulldatecheck}


So - as it stands the "date" part doesnt work - but when I move that to the top - then it works (and something under it doesnt filter).   Anyone ever have strange results like this? Anyone found a solution.

Thanks in Advance - this one has me very stumped.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 08 May 2018 at 7:29am
So do you want the data filter to be part of the else clause? if so you will need to put the Else clause criteria inside of parenthesis.  Also the text is difficult to read.  I suggest indenting embedded if statements.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 May 2018 at 7:53am
To add ...
you don't need the if-then, just stick with true false conditions.
Also if you are dealing with NULLs you either need to set the formula to using default values for nulls or use the null condition first, otherwise the row will not evaluate when it hits the null. Even if you set the formula to use defaults for Nulls you can still explicitly look for them in the formula

(not ({@nulldatecheck}))
AND
({?Client}="*ALLCLIENTS" OR {Client.DISPLAY_NAME}={?Client})
and
({?Location}="*ALLLOCATIONS" OR {Location.DISPLAY_NAME}={?Location})
and
({?Impact Type}="*ALLIMPACTS" OR {CVGCPLIMPACTM1.TYPE} = {?Impact Type})
and
(
     ({?Ticket Type}="Change" AND {CVGCPLIMPACTM1.NUMBER} startswith "C" )
     OR
     ({?Ticket Type}="Incident" AND {CVGCPLIMPACTM1.NUMBER} startswith "IM")
     OR
     ({?Ticket Type}="Problem" AND {CVGCPLIMPACTM1.NUMBER} startswith "PM")
)
AND
({?Program}="*ALLPROGRAMSS" OR {Program.DISPLAY_NAME}={?Program})
and
date({@relevant_date}) in {?DateRange}


Edited by DBlank - 08 May 2018 at 7:54am
IP IP Logged
GregF
Newbie
Newbie
Avatar

Joined: 04 May 2018
Location: United States
Online Status: Offline
Posts: 3
Quote GregF Replybullet Posted: 09 May 2018 at 8:46am
Thanks so much for replying - VERY MUCH appreciated.

Do others find that the select expert likes to move things around on you - and doesnt always keep things how you entered them.

In any case - I'm still testing - but I think the advice is working   
IP IP Logged
GregF
Newbie
Newbie
Avatar

Joined: 04 May 2018
Location: United States
Online Status: Offline
Posts: 3
Quote GregF Replybullet Posted: 09 May 2018 at 8:50am
As an FYI _ here is what it ended up with....

({?Program}="*ALLPROGRAMS" OR {Program.DISPLAY_NAME}={?Program}) and
({?Client}="*ALLCLIENTS" OR {Client.DISPLAY_NAME}={?Client}) and
(
Select {?Ticket Type}
Case "Change": {CVGCPLIMPACTM1.NUMBER} startswith "C"
Case "Incident": {CVGCPLIMPACTM1.NUMBER} startswith "IM"
Case "Problem": {CVGCPLIMPACTM1.NUMBER} startswith "PM"
Case "*ALLTYPES": true
) and
not {@nulldatecheck} and
{@relevant_date} in {?DateRange} and
({?Location}="*ALLLOCATIONS" OR {Location.DISPLAY_NAME}={?Location})

Edited by GregF - 09 May 2018 at 8:51am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 May 2018 at 2:54am
To your question, yes i do see the order in which I add conditions get swapped around in the actual SQL.

Glad you got it sorted out
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.