Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
shiveshsingh
Master
Master

Previous related error

I am having weekly product sales.

While using below condition, i am not getting correct results sometimes.

when a new product is added or removed in new week, then it's quantity is getting added to previous week sales (if new product is added) and vice versa.

if([Product Desc] = Previous([Product Desc]) and [Product No] = Previous([Product No]), Previous(Sales),Sales) as Previous_Sales

if previous week sales is 40 and current week sales is 50 with new product having 5 as sales, then using above logic i am getting 45 as previous week sales.

Can any one help in correcting the logic?

5 Replies
martinpohl
Partner - Master
Partner - Master

did you correct order your datas (so the correct previous line is found)

can you post your script here?

and why do you expect 45. for that the script shoul be

previous(Sales)+Sales

right?

regards

Anil_Babu_Samineni

There is no week in your statement, Try to create inline and help us to need output

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
shiveshsingh
Master
Master
Author

ok, i'll try for inline script .

But when i put Week condition too, then current sales and previous sales are becoming equal

shiveshsingh
Master
Master
Author

I am expecting 40 but it is coming 45 due to  Previous(Sales) +Sales of new product(which is not present in previous week)

Anil_Babu_Samineni

Let's Consider with example

Product Desc, Product No, Sales

12, 10, 100

12, 10, 200

13, 20, 200

10, 30, 200

13, 20, 300

And, If you apply your condition. Outcome will be this

Product Desc, Product No, Sales, Product_Sales

12, 10, 100, 100

12, 10, 200, 100

13, 20, 200, 200

10, 30, 200, 200

13, 20, 300, 300

Does it make sense?

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)