Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
aresb
Creator
Creator

How to change a temporal dimension based on a filter

Hi everyone,

i've the dimension code_year_month which is a string contains 202001, 202002 202003...etc

I setup this sheet and i want that the table display the previous year showing 201901 201902...etc

aresb_0-1667553003865.png

How can i achieve that?

Labels (3)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

Derive attributes from your current field such as year,month, date in your data load script

As below 

 

,DATE(Date#(code_year_month&'01','YYYYMMDD')) AS MonthStartDate

,Year(Date#(code_year_month,'YYYYMM')) AS YEARFIELD 

,MONTH(Date#(code_year_month,'YYYYMM')) AS MONTHFIELD 

 

Then in charts you can use either of below expressions

=Sum({<YEARFIELD={"$(=MAX(YEARFIELD,2))"}>}Something)

OR

=Sum({<MonthStartDate={">=$(=Date(Yearstart(MAX(MonthStartDate),-1)))<=$(=Date(Yearend(MAX(MonthStartDate),-1)))"}>}Something)

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

1 Reply
vinieme12
Champion III
Champion III

Derive attributes from your current field such as year,month, date in your data load script

As below 

 

,DATE(Date#(code_year_month&'01','YYYYMMDD')) AS MonthStartDate

,Year(Date#(code_year_month,'YYYYMM')) AS YEARFIELD 

,MONTH(Date#(code_year_month,'YYYYMM')) AS MONTHFIELD 

 

Then in charts you can use either of below expressions

=Sum({<YEARFIELD={"$(=MAX(YEARFIELD,2))"}>}Something)

OR

=Sum({<MonthStartDate={">=$(=Date(Yearstart(MAX(MonthStartDate),-1)))<=$(=Date(Yearend(MAX(MonthStartDate),-1)))"}>}Something)

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.