13 Replies Latest reply: Mar 14, 2014 10:28 AM by Fabrice Aunez

# Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

Hello Help please! Need to calculate the sum of the week for the current year (eg 2014) but provided that if for that same week had data for the last year (2013). If data for the same week last year was not - sale this week should not be exposed to the sum. And painfully hard ...

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

Hi,

in that case, when you do NOT have any sales_data for a specific week last year - will there be a 0 or just nothing?

=> Depending on that, you have to build your query.

With set_analysis, it's actually not that hard.

Best regards,

DataNibbler

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

(I do not speak in English, and could not quite understand). In the table, if there are no sales (Summ) then there is no record on the week against.

Probably using set_analysis it is not difficult to do but I can not for several days of heavy ..

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

Hi,

just tried it out:

=> In this case, a simple IF()_construct should be sufficient:

=> Change your formula for 2014 to
>>> IF(SUM ({<year={'2013'}>} Summ)  <> 0, SUM ({<year={'2014'}>} Summ)) <<<

==>> That way, your sales_data for 2014 will only be displayed in case the sales_data for 2013 is <>0.

HTH

Best regards,

DataNibbler

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).
 RestNum IF(SUM ({} Summ)  > 0, SUM ({} Summ)) 2013 2014 55980 149 113 125 871 149 113 56284 82 243 229 575 82 243 56525 105 941 236 492 105 941 59045 - 0 38 485 60385 - 0 77 555 453 337 591 938 453 337

Thank you. These really are not displayed if in 2013 there were no sales! But the amount is still considered full. And should that be not considered. Help please! ..

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

Ahtoh,

The result for each RestNum seems to be correct.

* If you have 0 in 2013, you get a Null() result: the dash: -

* If you have a result > 0, you have the 2014 data

The aggregation is not correct because you get the 2014 sum.

Try to do : sum(aggr(YourCurrentExpressionWithTheIF, RestNum))

Fabrice

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

I feel that you are right! But with such a formula he believes all the data again. I do not understand ..: (

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

I will do a test

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

I have no words as you will be grateful!

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

Ahtoh,

On a db of mine, I have done that:

sum({<Customer={"=sum({<Month={3}>} Amount)>0"}>} Amount)

I get only the customers where the Amount for the 3d month > 0. I have a good total. There is a set (sum > 0) into a set (on customer that I want to limit).

For you, if I transpose to your db, try sth like:

sum({<RestNum={"=sum({<Year={2013}>}, Summ) > 0"}>} Summ)

Fabrice

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).
 week 1 1 1 RestNum sum({}, Summ) > 0"}>} Summ) 2013 2014 55980 0 125 871 149 113 56284 0 229 575 82 243 56525 0 236 492 105 941 59045 0 0 38 485 60385 0 0 77 555 0 591 938 453 337

I now have shows all zeros .. (I can not ask you but if still possible - attach file structure in the first message - it can accurately check all)

• ###### Re: Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

It is not possible because I have the Personal Edition (I would ahve attached it and done the test with your data)

Sorry for that

Picture 1

A pivot table with the corresponding syntax

A pivot table with Sum(Amount) to show the stucture

Picture 2

The first pivot table, I have added Sum(Amount) to show that the syntax returns 0 in that case

I cannot attach your qvw, you will be able to attach mine. That is the last sheet.

Fabrice

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

Seems to happen, I am very grateful to you, thank you very much! You helped me a lot!

• ###### Re: Calculate the sum of the week for the current year (eg 2014), but on the condition that if in this same week data were last year (2013).

you are the wellcome