Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
Carlos2
Contributor II
Contributor II

Compare same periods different years

I want to compare different years but same periods, so it would be for 2020 until today and same period for 2019

 

For 2020 I have this formula:

Sum({<[Fecha - hora.autoCalendar.Year]= {$(=Max(Year([Fecha - hora.autoCalendar.Year])))}>}[Total])

 

For 2019 I have this formula:

Sum({<[Fecha - hora.autoCalendar.Year]= {$(=Max(Year([Fecha - hora.autoCalendar.Year]-1)))}>}[Total])

 

How do I compare two years but for the same period of time as the Max(Year([today])

Labels (1)
1 Solution

Accepted Solutions
srdheekonda
Contributor III
Contributor III

Try using this formulas for CY YTD and PY YTD: based on your date_column format change the date format to make it work.

CY YTD:

SUM({$<DATE_COLUMN={">=$(=DATE(YearStart(TODAY()),'YYYY-MM-DD'))<=$(=DATE(TODAY(),'YYYY-MM-DD'))"}>}TOTAL)

PY YTD:

SUM({1<DATE_COLUMN={">=$(=DATE((YearStart(AddYears(TODAY(),-1))),'YYYY-MM-DD'))<=$(=DATE(AddYears(TODAY(),-1),'YYYY-MM-DD'))"}>}TOTAL)

hope this helps

View solution in original post

2 Replies
Saryk
Partner - Creator II
Partner - Creator II

Hello,

 

You're interested in a year-to-date analysis.

Check this page, the YTD section.

srdheekonda
Contributor III
Contributor III

Try using this formulas for CY YTD and PY YTD: based on your date_column format change the date format to make it work.

CY YTD:

SUM({$<DATE_COLUMN={">=$(=DATE(YearStart(TODAY()),'YYYY-MM-DD'))<=$(=DATE(TODAY(),'YYYY-MM-DD'))"}>}TOTAL)

PY YTD:

SUM({1<DATE_COLUMN={">=$(=DATE((YearStart(AddYears(TODAY(),-1))),'YYYY-MM-DD'))<=$(=DATE(AddYears(TODAY(),-1),'YYYY-MM-DD'))"}>}TOTAL)

hope this helps