Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal - Variable declaration

Status
Not open for further replies.

kavithapedada

Programmer
Apr 26, 2012
8
SG
Shared NumberVar m1 ;
Shared NumberVar m2;
Shared NumberVar m3;
Shared NumberVar m4;
Shared NumberVar m5;
Shared NumberVar m6;
Shared NumberVar m7;
Shared NumberVar m8;
Shared NumberVar m9;
Shared NumberVar m10;
Shared NumberVar m11;
Shared NumberVar m12;
if {@mONTH} = 1 then
m1= {@mONTH} ;
if {@mONTH} = 2 then
m2 = {@mONTH};
if {@mONTH} = 3 then
m3 = {@mONTH} ;
if {@mONTH} = 4 then
m4= {@mONTH} -1;
if {@mONTH} = 5 then
m5 = {@mONTH} -2;
if {@mONTH} = 6 then
m6 = {@mONTH} -3;
if {@mONTH} = 7 then
m7= {@mONTH} - m6 - m3;
if {@mONTH} = 8 then
m8 = {@mONTH} - m6 - m3;
if {@mONTH} = 9 then
m9 = {@mONTH} - m6- m3;
if {@mONTH} = 10 then
m10= {@mONTH} - m9 - m6 -m3;
if {@mONTH} = 11 then
m11 = {@mONTH}- m9 - m6 - m3;
if {@mONTH} = 12 then
m12 = {@mONTH} - m9 - m6 - m3;

if {@mONTH} = m1 + m2 + m3 and {@Year} = {?YEAR}
then "This year Q1 "
if {@mONTH} = m1 + m2 + m3 and {@Year} = {?YEAR} -1
then "Last year Q1 "
Variance = Q1 This Year - Last year
then "This year Q1 "
if {@mONTH} = m4 + m5 + m6 and {@Year} = {?YEAR}
then "This year Q2 "
etc.............................


Here {@MONTH} = Formula to get the month from Date

i want to display in the Cross Tab like " Q1 - This Year" and Q1 - Last Year" and Variance etc...

Iam unable to to use the above logic some where id i did mistake please help me to clear it

 
You need to use := instead of : to set the variables, like this:

if {@mONTH} = 1 then
m1 := {@mONTH};

-LB
 
if {@mONTH} = 1 then
m1 := {@mONTH};

if i use this syntax its giving the below error

""A PRINT TIME FORMULA THAT MODIFIES VARIABLES IS USED IN A CHART OR MAP
 
You didn't mention that you were trying to chart with these formulas. The error message is because you are using variables. If you must chart these, then you have to use a complex technique "Charting on Print-time Formulas" as shown here:

Why are you using shared variables in the first place? What is the purpose of the adjustments you are making to values?

-LB
 
Hi

I want to calu the Last year and this year Q1 values with conditions like

in Paramters if they enter: Period = 10
then the Its Q4 , so the values need to come like 10 - 9 -6-3( Need to subtract the previous Quartes values) for the present Qurater value

Regards,
Kavitha.
 
Please show the content of {@Month}. In looking at your formula, it doesn't make sense. You are just saying if a month = 1 then you are setting it equal to 1, etc.

Also, you seem to want to subtract other values, so is your value field cumulative? Please show some sample data and label it.

You did not explain why you are using shared variables.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top