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

Need to create Year to year treand in line chart

Hi,

I need to create year to year treand line chart, i have month, year and user ID columns. My X asis should be month and y axis should show two lines of years with count of user Id. If i select present year it should show only the present year and previous year treand. I have 2022,2021,2020,2019 year if i select 2021 it should show 2021 and 2020 year lines. Please help

1 Reply
abhijitnalekar
Specialist II
Specialist II

HI @sharu055 ,

Please do as below.

abhijitnalekar_0-1648796678837.png

 

and your expression will be as bellow.

Sum({$ <Year=,Date={"$(vCYTD)"}>+<InvoiceYear=,InvoiceDate={"$(vLYTD)"}>} Total)

 

Create below variables in the app.
vCYTD:
'>=' & Date(YearStart(Max(Date)), 'MM/DD/YYYY') & '<=' & Date((Max(Date)), 'MM/DD/YYYY')

vLYTD:
='>=' &
if(GetSelectedCount(Year)<=1,
Date(YearStart(Max(Date),-1), 'MM/DD/YYYY'),Date(YearStart(Max(Date),(minYear)-max(Year))), 'MM/DD/YYYY') )
& '<=' &
if(GetSelectedCount(Year)<=1,
Date(addyears(Max(Date),-1), 'MM/DD/YYYY'),Date(addyears(Max(Date),(min(Year)-max(Year))), 'MM/DD/YYYY'))

 

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!