Skip to Content

How to create variables in crystal reports? (not crystal report enterprise)

Hi,

I wanna create a variable as below...

sum(sale) where country = india

sum(sale) where country <> 'USA

I wanna use these measures in crosstab table.

how to create these. please help me

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • May 31, 2017 at 01:23 PM

    No need to use variables just create two formula

    @India

    If country = india then sales else 0

    repeat for USA

    This can then be used in Summaries or Crosstab

    Ian

    Add comment
    10|10000 characters needed characters exceeded

  • May 31, 2017 at 02:23 PM

    Simply insert a CrossTab with rows (or columns) being Country and the summarized value being Sales.

    Add comment
    10|10000 characters needed characters exceeded

  • May 31, 2017 at 03:20 PM

    I want as below....

    Where sale is a measure object. I wanna calculate india sale and other countries sale and use it.

    Thanks

    Riaz

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      I have created formula as you said

      if country in( 'india';'russia') then 'asia'

      else others

      I used that formula in crosstab. But I didn't get the sum of both coutries. I'm getting only russia value.

  • May 31, 2017 at 04:15 PM

    Can you show syntax as written in Crystal

    separator in a list should be , you appear to have used ;

    If syntax correct it should work.

    failing that split out to make sure you have india data

    if country = 'india' then 'india'

    else if country = 'russia' then 'Russia'

    else 'others'

    Ian

    Add comment
    10|10000 characters needed characters exceeded

    • Never seen this before. Your logic is correct except for use of round brackets an ;

      I would write as

      if {Country} in ['India','Russia']

      then 'Asia'

      else 'others'

      that is using square brackets, with comma separator. Also Others must be wrapped in speech marks