Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
everest226
Creator III
Creator III

max year rolling 12 months

I am using set Analysis trying to  get the data  of 12 months rolling but till last months only ,

my code

Count (DISTINCT {<Year={'$(=max(Year))'}, Month={"$(=month(date#(max({<Year={'$(=max(Year))'}>}Month)-1,'MM')))"}>} [user])

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Count (DISTINCT {<Year, Month, MonthYear = {"$(='>=' & Date(AddMonths(Max(MonthYear), -12),'YYYY-MMM') & '<' & Date(Max(MonthYear),'YYYY-MMM'))"}>} [user])

View solution in original post

11 Replies
sunny_talwar

Do you have a MonthYear field? If you don't, then try like this

LOAD Date,

          Date(MonthStart(Date), 'MMM-YYYY') as MonthYear

          ....

FROM ....

and then an expression like this:

Count (DISTINCT {<Year, Month, MonthYear = {"$(='<' & Date(Max(MonthYear),'MMM-YYYY'))"}>} [user])

everest226
Creator III
Creator III
Author

can we work around on this expression for same outcome also?

so the data will be 12 months rolling till last months

Count({<Year = {2017}>} DISTINCT [Authenticated user])

i have these on my script

LOAD CalendarTimeStamp,

     Timestamp(CalendarTimeStamp, 'M/D/YYYY h:mm TT') AS [Date Time],

     Date(MonthStart(Date(CalendarTimeStamp)), 'YYYY-MMM') AS [YYYY-MMM],

     Day(CalendarTimeStamp) AS Day,

     Day(CalendarTimeStamp) & ' ' & WeekDay(CalendarTimeStamp) AS [Day-Week],

     Week(CalendarTimeStamp) AS Week,

     Month(CalendarTimeStamp) AS Month,

     RowCount

FROM MinuteCalendar.qvd (qvd);

sunny_talwar

I am not sure I follow... can you share a sample?

everest226
Creator III
Creator III
Author

basically this apps is concurrency analyzer to read server log file,so where i ned to use Date(MonthStart(Date), 'MMM-YYYY') as MonthYear    ,, i tried to replace in as year did not work i do need that year field also.

Capture666666666.PNG

sunny_talwar

What did not work? I am still not sure I understand

everest226
Creator III
Creator III
Author

So i was able to get MonthsYear field but somehow it is not working in expression to get 12 months user till last months,, so as of today Jan 2017, chart  should have data from Jan 2016 to dec 2016

Count (DISTINCT {<Year={'$(=max(MonthYear))'}, Month-={"$(=month(date#(max({<Year={'$(=max(MonthYear))'}>}Month),'MM')))"}>} [ user])

1010.PNG

sunny_talwar

That is not the expression I gave. I gave you this.... did you try this?

Count (DISTINCT {<Year, Month, MonthYear = {"$(='<' & Date(Max(MonthYear),'MMM-YYYY'))"}>} [user])

everest226
Creator III
Creator III
Author

yes i did , Expression is ok but the chart says no data to display.

everest226
Creator III
Creator III
Author

do i need to use monthsyear  field in dimension  also