Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Build IN clause Post Reply Post New Topic
Author Message
gmac
Newbie
Newbie


Joined: 21 Jul 2014
Online Status: Offline
Posts: 3
Quote gmac Replybullet Topic: Build IN clause
     Posted: 22 Jul 2014 at 8:10pm
hello,

I have a formula that I can not write well. Please help me to solve the task.


There is a running total evaluate:
{report.mak} in [array]

The [array] I would like to build in a formula (depending on a parameter):
Select {?Pmak}
  Case "fruit": "apple", "pear", "peach"
  Case "drink": "cola", "water", "wine"


How do you write the formula to make it work the IN clause?

The goal of this (if {?Pmak} = "fruit")
{report.mak} in ["apple", "pear", "peach"]


I tried these versions, but none of them worked:
  Case "fruit": "apple" + "," + "pear" + "," + "peach" (I got an incorrect results)
  Case "fruit":  array ["apple", "pear", "peach"] (I got an error message)

Thanks
gmac

ps: Sorry for my English

IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 23 Jul 2014 at 12:45am
So if I understand correct:
When your parameter says "fruit", you want the text "apple, pear, peach", and when it says "drink" it should say "cola, water, wine"?

if {?Pmak} = 'fruit' then 'apple, pear, peach' else
if {?Pmak} = 'drink' then 'cola, water, wine'
IP IP Logged
gmac
Newbie
Newbie


Joined: 21 Jul 2014
Online Status: Offline
Posts: 3
Quote gmac Replybullet Posted: 23 Jul 2014 at 2:09am
Not really. Your formula result is a string. If I use this formula in a running total, I not come really result. Because the IN clause work with array, not a string.

My goal is the correct running total:
{report.mak} in {@formula}

But I can't write the correct formula.

Thanks!
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 23 Jul 2014 at 6:43am
this might work

({?Pmak} = 'fruit' and {report.mak} in ['apple', 'pear', 'peach'] or
({?Pmak} = 'drink' and {report.mak} in ['cola', 'water', 'wine'])
IP IP Logged
gmac
Newbie
Newbie


Joined: 21 Jul 2014
Online Status: Offline
Posts: 3
Quote gmac Replybullet Posted: 23 Jul 2014 at 8:35pm
Kostya1122, when I write your code in the running total evaluate, the result is good. But you don't use formula, you write every condition in the running total. It's not good for me, because I have more running total and I want to display the array in the report.

I want a formula in which the array is created, and I want use this formula in the running total evaluate.

Thanks



Edited by gmac - 23 Jul 2014 at 8:36pm
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