Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
sagarjagga
Creator
Creator

Current Year and Previous Year sales set analysis in a table

Hi All,

 i have a requirement where i need to display the current year and previous year amt in a table corresponding to the year.

i.e below is my data set 

YearAmt
2015100
2016200
2018300
2019400

 

My desired output is 

Yearcurrent year amtprevious year amt
20151000
2016200100
2018300200
2019400300

 

Through script , it is easily possible. Above function will also work but if the order of the Year has been changed then it will not work. Looking to do in the Set Analysis itself

Labels (1)
4 Replies
Kashyap_R
Partner - Specialist
Partner - Specialist

Hi 

Try this

if(ISNULL(Above(Sum([qq.Amt]),1)),0,Above(Sum([qq.Amt]),1))

Hope it helps 

Thanks

Thanks and Regards
Kashyap.R
lanlizgu
Creator III
Creator III

You can add in the table a dimension as follow

=date(AddYears( date#(Year, 'YYYY'),-1),'YYYY')

so you could display the previous year with the Amt. The thing is that the previous year of 2018 is 2017, not 2016 as you are expecting. If so, you could add to the table in the script a column with the previous year that you are expecting and display this new field as the dimension in the table.

sagarjagga
Creator
Creator
Author

Thanks for your Response Kashyap .

Any other function other than above?

Kashyap_R
Partner - Specialist
Partner - Specialist

Hi 

try doing it in the back end using peek function and create a new column as previous.

Hope this helps 

Thanks

 

 

Thanks and Regards
Kashyap.R