10 Replies Latest reply: Oct 28, 2011 10:55 AM by nima ebrahimzadeh

# Rows calculatein in script

Hi All,

I'm trying to create a calculation in script like this:

Here is my table:

CountriesSalesForcast
US4550
Spain3240

What I want is to create the last line in the script.

Thanks

• ###### Re: Rows calculatein in script

Nima,

table:
Countries,
Sales,
Forecast
FROM <source>;

sum(Sales) as Sales,
sum(Forecast) as Forecast
RESIDENT table

• ###### Rows calculatein in script

Correct, thanks

• ###### Rows calculatein in script

Thanks Michael,

I will try it with my real data , hope it works.

Thanks

Nima

• ###### Rows calculatein in script

Hello Micheal,

Another question for you. If we want to do a calculation like  Canada - Spain , how do we do?

Thanks

• ###### Rows calculatein in script

Nima,

It will be similar, the additional piece of code:

sum(Sales) as Sales,

sum(Forecast) as Forecast

RESIDENT table

• ###### Rows calculatein in script

Hello,

I mean if we want to Subtract canada from Spain  :   Canada " - " Spain

What can we do?

Thanks

• ###### Rows calculatein in script

Nima,

Why would you want to do it in the script?  This is something that more often makes sense (and much more flexible and easy) on the front-end.
Anyway, if it must be in the script for some reason, try this:
sum(if(Countries='Canada', Sales, - Sales) as Sales,
RESIDENT table

• ###### Rows calculatein in script

Michael,

I updated the discussion and add the real table as attachment.

The reason I need to do it in script is : If I have two measures for example Weight and Dollar and I want to the calculation , as far as I know it's not possible.If you take a look at the attached file you will see that I have weight in the report and I did my calculation in expression , like Sales+ Forecast and  it works for just Weight but if I have Dollar in the report as another measure there is no way to do it.

If you have any solution , I would appreciate.

Thanks,

Nima

• ###### Re: Rows calculatein in script

Hi Nima,