Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

scenario

Hi friends,

   

Product_id                       Date     amount
A1/5/2013100
A1/6/2014200
A1/7/2015300
B1/7/2013200
B1/8/2014300
B1/9/2015400

this is my table here my requirement how to get last 2 years total(100+200)=300

as well how to get last 3 years amount 600

how to achieve this , please help me on this

8 Replies
MK_QSL
MVP
MVP

Do you want this at back end?

If front end, where you are going to use this?

In chart or in text box?

Anil_Babu_Samineni

What was the expected output? Does this happen with Product wise or what? Would you describe more

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Not applicable
Author

Hi Manish,

his requirment is

Product    2 years                       3 years

A               (100+200)= 300          100+200+300

B        same like A .



in front end only.


Not applicable
Author

his requirment is

Product    2 years                       3 years

A               (100+200)= 300          100+200+300

B        same like A .



in front end only.

Not applicable
Author

Could you suggest me best material for Set analysis. and performance improve steps.

Not applicable
Author

Could you suggest me best material for Set analysis. and performance improve steps.

Anil_Babu_Samineni

His means (User)

Can you try something like this

241345:

LOAD * Inline [

Product_id,  Date1,    amount

A, 1/5/2013, 100

A, 1/6/2014, 200

A, 1/7/2015, 300

B, 1/7/2013, 200

B, 1/8/2014, 300

B, 1/9/2015, 400

];

Final_Table:

NoConcatenate

LOAD *,Right(Date1,4) as Year

Resident 241345;

DROP Table 241345;

Take Straight Table

Dimension is -- Product_id

For 2 Years -- Sum({<Year = {"$(='<' & Max(Year))"}>} amount)

For 3 Years -- Sum(amount)

Seems O/P this, For Ref, Enclose is attached

Capture.PNG

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
simran04
Contributor II
Contributor II

Please try the below code:

INPUT:

LOAD * INLINE [

Product_id,Date,amount

A,1/5/2013,100

A,1/6/2014,200

A,1/7/2015,300

B,1/7/2013,200

B,1/8/2014,300

B,1/9/2015,400

];

INPUT1:

LOAD Product_id,

SUM(If((Year(Date#(Date,'DD/MM/YYYY'))='2013' OR Year(Date#(Date,'DD/MM/YYYY'))='2014'),amount,0)) as twoyearssum,

Sum(amount) as Threeyearssum

resident INPUT

group by Product_id;