cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports: using "like" with "in"

former_member548403
Participant
0 Kudos

I have a report that uses below formula.

if {?Day_Night} = 'All' then
(({?Position}='ALL' or {Command.category2} like {?Position} & "*") and {?Day_Night}='All')
else if {?Day_Night}={command.day} then
(({?Position}='ALL' or {Command.category2} like {?Position} & "*") and {?Day_Night}={command.day})
else if {?Day_Night}={command.night} then
(({?Position}='ALL' or {Command.category2} like {?Position} & "*") and {?Day_Night}={command.night})

The {?Position} parameter was a single selection thus far, but now I need to change that to allow multiple selections. I tried substituting "like" with "in" and although there was no error, the report did not show any data. Is there a way to use array method while still allowing the report to use "like" or " * "?

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor

Something you might try is to change "like" to "startswith", which will work with the multi-select array.

-Dell

former_member548403
Participant
0 Kudos

Thanks! I will try that!

former_member548403
Participant
0 Kudos

Changed the formula like this and then changed the parameter to multiple selection. Now i'm getting the array error....

if {?Day_Night} = 'All' then
(({?Position}='ALL' or {Command.category2} startswith[{?Position}] and {?Day_Night}='All'))
else if {?Day_Night}={command.day} then
(({?Position}='ALL' or {Command.category2} startswith[{?Position}] and {?Day_Night}={command.day}))
else if {?Day_Night}={command.night} then
(({?Position}='ALL' or {Command.category2} startswith[{?Position}] and {?Day_Night}={command.night}))

DellSC
Active Contributor

Remove the brackets around {?Position} and put a space after "startswith". If {?Position} is multi-select, it will automatically be an array, so you don't need the brackets.

-Dell

Answers (0)