Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
Qlik Launches Open Lakehouse and advanced agentic AI experience in Qlik Answers! | LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
cfountain72
Creator II
Creator II

Monthly YOY Line Chart

Hello,

I am trying to replicate line charts that are currently showing in an SSRS report we have. They are simple, but I can't quite figure out how to make Qlik Sense generate them. It is monthly chart with two lines to show Monthly YOY comparisons. One line shows the last 12 full months (Apr 2024 - Mar 2025) and the other line showing the previous 12 months (Apr 2023 - Mar 2024). This screenshot shows four of these charts...

cfountain72_0-1744389988585.png

Any suggestions?

Thanks in advance,

Chris

Labels (4)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

Consider the script beneath. It will generate this chart. (Note that the numbering of month will change for every month you run the script)

Vegar_0-1744651347074.png

Spoiler
SET SetDateFormat = YYYY-MM-DD;
LET base_date = today();
LET base_month_no = num(month(base_date));

LOAD

   flight_number,
   carrier,
   dayname(date) as date,
   Yearname (date,0, $(base_month_no)) as year,
   DUAL(Month(date) , num(Month(MonthName(date,+1-$(base_month_no)))) ) as month
inline [
flight_number,carrier,date
AM7520,AM,2024-01-01
TG3007,TG,2023-09-27
ET1495,ET,2024-09-25
KL6764,KL,2024-12-27
KL9925,KL,2024-02-05
QF1061,QF,2024-04-29
AM2109,AM,2024-07-30

LA5197,LA,2024-08-18
SK4515,SK,2023-11-23
AA9129,AA,2024-09-13
ET1460,ET,2023-09-15
KL9046,KL,2024-11-03
DL1090,DL,2024-02-24
DL2537,DL,2023-11-11
DL2397,DL,2023-06-06
TG9054,TG,2024-06-08
WN9851,WN,2024-01-02
TG3782,TG,2024-04-04
NZ3507,NZ,2024-01-02
AZ6840,AZ,2024-02-26
LH5030,LH,2024-01-13
AV1217,AV,2024-10-28
AM5515,AM,2024-04-07
DL5388,DL,2023-05-08
NH6666,NH,2024-10-10
AA7447,AA,2023-11-16
SA8061,SA,2025-01-21
KE2030,KE,2024-11-28
SK4469,SK,2024-02-16
KE9571,KE,2024-07-02
AZ4478,AZ,2023-12-07
LH8791,LH,2024-02-07
SK7593,SK,2024-05-27
AI5828,AI,2024-10-27
KE9114,KE,2025-03-30
SQ8042,SQ,2025-04-08
AZ2669,AZ,2024-01-10
QF3865,QF,2024-04-08
SA1075,SA,2023-06-07
AZ2355,AZ,2024-06-01
SA8434,SA,2023-11-30
WN1086,WN,2025-04-11
KE3096,KE,2023-04-27
ET5654,ET,2024-11-16
SQ8492,SQ,2023-12-12
QR8829,QR,2023-07-30
BA4267,BA,2023-11-19
AI4218,AI,2023-07-05
AI1179,AI,2024-05-26
NZ9504,NZ,2023-06-01
LH2095,LH,2024-09-10
DL4345,DL,2023-11-01
NH6529,NH,2024-03-31
WN3384,WN,2023-05-12
NZ2165,NZ,2023-06-11
NZ8857,NZ,2023-12-24
AM3158,AM,2025-01-27
QF5992,QF,2024-01-29
NZ8553,NZ,2023-04-24
ET7440,ET,2023-08-01
WN7861,WN,2024-06-22
AA4128,AA,2025-01-23
AA1658,AA,2025-01-24
AM3648,AM,2023-10-04
IB9980,IB,2024-07-17
CX3807,CX,2024-06-08
LA7200,LA,2024-05-05
AF1538,AF,2025-02-23
LA5570,LA,2024-03-25
AF8531,AF,2023-10-16
AI9365,AI,2023-12-12
TG7299,TG,2023-06-15
IB7381,IB,2023-05-24
EK7131,EK,2024-03-08
NZ8951,NZ,2024-04-24
SA7749,SA,2024-06-23
KL4500,KL,2023-11-05
TG4753,TG,2023-11-17
SA5940,SA,2024-10-29
TG2024,TG,2024-11-10
BA1442,BA,2024-10-09
LH2485,LH,2024-07-15
WN9586,WN,2023-06-06
QF7187,QF,2024-01-28
AZ7873,AZ,2024-12-03
NZ1302,NZ,2024-10-01
LA6061,LA,2025-01-30
WN2211,WN,2025-03-12
AC8565,AC,2023-06-10
LH6336,LH,2023-04-19
DL8764,DL,2024-04-25
AF6433,AF,2023-08-26
QR8922,QR,2023-07-09
LH7664,LH,2024-03-16
AA6481,AA,2023-06-12
SK5933,SK,2024-07-24
AI3110,AI,2024-01-16
UA1658,UA,2024-01-18
KL4871,KL,2024-06-14
AV9933,AV,2023-09-01];

View solution in original post

6 Replies
Vegar
MVP
MVP

It can be solve by adjusting your year start or adding a set of fiscal year dimensions to your data model.

Yearname (date,0 4) as year_starting_in_april,

DUAL(Month(date) ,              num(Month(MonthName(date, +1- 4))) )  as month_starting_in_april

cfountain72
Creator II
Creator II
Author

Thanks for the suggestion! However, it's not based on Fiscal periods, so the start month will not always be April. The chart should always show the last 24 months of activity, grouped by the last 12 months vs the 12 months prior. So, for example, in June 2025, it would show Jun 2024 - May 2025 vs Jun 2023 - May 2024. Does that make sense?

diagonjope
Partner - Creator III
Partner - Creator III

Vegar
MVP
MVP

It makes sense, but if it is the current date (today) that affects which month should be first then you could just adjust the fiscal period every time you run the script.

 

Vegar
MVP
MVP

Consider the script beneath. It will generate this chart. (Note that the numbering of month will change for every month you run the script)

Vegar_0-1744651347074.png

Spoiler
SET SetDateFormat = YYYY-MM-DD;
LET base_date = today();
LET base_month_no = num(month(base_date));

LOAD

   flight_number,
   carrier,
   dayname(date) as date,
   Yearname (date,0, $(base_month_no)) as year,
   DUAL(Month(date) , num(Month(MonthName(date,+1-$(base_month_no)))) ) as month
inline [
flight_number,carrier,date
AM7520,AM,2024-01-01
TG3007,TG,2023-09-27
ET1495,ET,2024-09-25
KL6764,KL,2024-12-27
KL9925,KL,2024-02-05
QF1061,QF,2024-04-29
AM2109,AM,2024-07-30

LA5197,LA,2024-08-18
SK4515,SK,2023-11-23
AA9129,AA,2024-09-13
ET1460,ET,2023-09-15
KL9046,KL,2024-11-03
DL1090,DL,2024-02-24
DL2537,DL,2023-11-11
DL2397,DL,2023-06-06
TG9054,TG,2024-06-08
WN9851,WN,2024-01-02
TG3782,TG,2024-04-04
NZ3507,NZ,2024-01-02
AZ6840,AZ,2024-02-26
LH5030,LH,2024-01-13
AV1217,AV,2024-10-28
AM5515,AM,2024-04-07
DL5388,DL,2023-05-08
NH6666,NH,2024-10-10
AA7447,AA,2023-11-16
SA8061,SA,2025-01-21
KE2030,KE,2024-11-28
SK4469,SK,2024-02-16
KE9571,KE,2024-07-02
AZ4478,AZ,2023-12-07
LH8791,LH,2024-02-07
SK7593,SK,2024-05-27
AI5828,AI,2024-10-27
KE9114,KE,2025-03-30
SQ8042,SQ,2025-04-08
AZ2669,AZ,2024-01-10
QF3865,QF,2024-04-08
SA1075,SA,2023-06-07
AZ2355,AZ,2024-06-01
SA8434,SA,2023-11-30
WN1086,WN,2025-04-11
KE3096,KE,2023-04-27
ET5654,ET,2024-11-16
SQ8492,SQ,2023-12-12
QR8829,QR,2023-07-30
BA4267,BA,2023-11-19
AI4218,AI,2023-07-05
AI1179,AI,2024-05-26
NZ9504,NZ,2023-06-01
LH2095,LH,2024-09-10
DL4345,DL,2023-11-01
NH6529,NH,2024-03-31
WN3384,WN,2023-05-12
NZ2165,NZ,2023-06-11
NZ8857,NZ,2023-12-24
AM3158,AM,2025-01-27
QF5992,QF,2024-01-29
NZ8553,NZ,2023-04-24
ET7440,ET,2023-08-01
WN7861,WN,2024-06-22
AA4128,AA,2025-01-23
AA1658,AA,2025-01-24
AM3648,AM,2023-10-04
IB9980,IB,2024-07-17
CX3807,CX,2024-06-08
LA7200,LA,2024-05-05
AF1538,AF,2025-02-23
LA5570,LA,2024-03-25
AF8531,AF,2023-10-16
AI9365,AI,2023-12-12
TG7299,TG,2023-06-15
IB7381,IB,2023-05-24
EK7131,EK,2024-03-08
NZ8951,NZ,2024-04-24
SA7749,SA,2024-06-23
KL4500,KL,2023-11-05
TG4753,TG,2023-11-17
SA5940,SA,2024-10-29
TG2024,TG,2024-11-10
BA1442,BA,2024-10-09
LH2485,LH,2024-07-15
WN9586,WN,2023-06-06
QF7187,QF,2024-01-28
AZ7873,AZ,2024-12-03
NZ1302,NZ,2024-10-01
LA6061,LA,2025-01-30
WN2211,WN,2025-03-12
AC8565,AC,2023-06-10
LH6336,LH,2023-04-19
DL8764,DL,2024-04-25
AF6433,AF,2023-08-26
QR8922,QR,2023-07-09
LH7664,LH,2024-03-16
AA6481,AA,2023-06-12
SK5933,SK,2024-07-24
AI3110,AI,2024-01-16
UA1658,UA,2024-01-18
KL4871,KL,2024-06-14
AV9933,AV,2023-09-01];

cfountain72
Creator II
Creator II
Author

Thanks! This is exactly what I was trying to do.