Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
dberkesacn
Partner - Creator III
Partner - Creator III

Current YTD vs Previous whole year showing together

Hi,

I have a line chart where I would like to display the current YTD and the previous full year.

The prev full year should be displayed with the current year values together e.g from JAN 2018 till DEC 2018 and not from JAN 2017 till DEC 2017.

With this, the prev vs curr can be compared easily.

I was able to solve it, with above function i shifted the previous year's value but when I do selection I lose prev year values.

Which make sense since Qlik Sense ( ) evaluate the prev year expression in the selected dims (2018) .

could you suggest solution which can be applied in frontend?

Thanks,

Daniel

13 Replies
niclaz79
Partner - Creator III
Partner - Creator III

Hi,

I would use the dimension of Month and Year as two dimensions, so the year will be applied for the name of the lines. That way you get no issue with showing 2017 and 2018 on the same axis and can apply a simple set-analysis on the expression instead.

amit_gupta
Contributor III
Contributor III

Daniel,

Following Expression will work in Case we are having data till date

Sum({<Year={">=$(=Max(Year-1))<=$(=Max(Year))"}>}Sales)


In Case, if we are having forecast data.

We need to modify expression

I hope, It will work for you.

dberkesacn
Partner - Creator III
Partner - Creator III
Author

Hi Amit, i need two lines one line is showing current ytd and the second line is previus full year ( i do used set analysies) BUT the previous full year should be displayed from 2018.01 - 2018. 12. I used above in the previius expression. But when i selected on chart the previous lost.

OmarBenSalem

Let's assume u have this data:

Load * Inline [

Year,Month,Measure

2018,01,100

2018,02,150

2018,03,120

2018,04,140

2018,05,100

2018,06,200

2018,07,220

2018,08,150

2018,09,170

2018,10,180

2018,11,100

2018,12,190

2017,01,150

2017,02,180

2017,03,200

2017,04,300

2017,05,180

2017,06,110

2017,07,90

2017,08,160

2017,09,150

2017,10,200

2017,11,300

2017,12,190

];

as dim : Month (without Year), only months

Measures:

1)Sum({<Year={"$(=max(Year))"},Month={"<=$(=max(Month))"}>}Measure) Label it : Max(Year)

2)Sum({<Year={"$(=max(Year)-1)"},Month>}Measure) Label it : Max(Year)-1

result:

Capture.PNG

If u have a date field; change ur measures as follow:

1)Sum({<Month, Year={"$(=max(Year))"},Date={"<=$(=max(Date))"}>}Measure) Label it : Max(Year)

2)Sum({<Year={"$(=max(Year)-1)"},Month,Date>}Measure) Label it : Max(Year)-1

dberkesacn
Partner - Creator III
Partner - Creator III
Author

Hi with just month dimension it worked for me as well, but i need Year Month.

OmarBenSalem

Have u tried it? It works no matter the dimension.

Capture.PNG

dberkesacn
Partner - Creator III
Partner - Creator III
Author

I would like to present the previous year's data in the current year.  from 2018 Jan - 2018 Dec

OmarBenSalem

Are u being serious? Is this what u're aiming for, it's INCORRECT.

Good luck

dberkesacn
Partner - Creator III
Partner - Creator III
Author

yes, since we call it reference not previous. It makes sense comparing the actual to a reference (which is the previous)