Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculate Sum of selected values in a column?

Hi All,

First of all I tried searching for this topic did not find it...if there is already one please redirect me to that link.

Problem : I have two columns called sales_increment and profit_increment. I have to calculate the sum of all sales_increment when sales_increment > 0 and profit_increment>0.

I am trying to display the result in a text box.

Expression used :

Sum(If(INCREMENTAL_SALES>'0' and INCREMENTAL_PROFIT>'0',INCREMENTAL_SALES))

I am not getting the right answer. Can anyone please look into this??

15 Replies
Not applicable
Author

Sokkorn,

I have one more doubt here. I loaded the dataset and then changed the dataset...that is deleted some rows from the dataset. To reflect the changes I reloaded it, but I could not observe any changes. Is there any other method to reload the changed data?

Sokkorn
Master
Master

Hi,

Let do this expression (with distinct keyword)

=SUM({$<INCREMENTAL_SALES={">0"}, INCREMENTAL_PROFIT={">0"}>} DISTINCT INCREMENTAL_SALES)

***Check your datasource to find duplicate record.

Regards,

Sokkorn

Not applicable
Author

Hi,

After changing the data set..looks like I am getting the correct result

I did not try wiht distinct..because there are no records which are the same

Also, I wanted to know if we can write this condition programtically ie.

if(incremntal_sales > 0 && incremental_profit >)

{

    variable = incrmental_sales

}

else

{

variable = variable + incremental_sales

}

If this is possible, how do I write it in Qlikview( i.e where nd the syntax)

Thanks for your help!

Sokkorn
Master
Master

Hi,

It seem you want to achieve accumulate incremental_sale. Am I right?

Regards,

Sokkorn

Not applicable
Author

Yes accumulate value for rowa which satify that condition

Sent from my iPhone

On Jun 12, 2012, at 12:39 AM, Sokkorn Cheav <

Sokkorn
Master
Master

Hi,

Let try this expression

RangeSum(Above(Total SUM({$<INCREMENTAL_SALES={">0"}, INCREMENTAL_PROFIT={">0"}>} DISTINCT INCREMENTAL_SALES),0,RowNo(TOTAL)))

See sample attached file.

**Can remove distinct if your datasource is ok.

Regards,

Sokkron