Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Curent month vs previous

Hi All,

need help with set analysis. I have a yearmonth field - StatusHistory.YearMonth

i need to count sabid for curent month and previous month..

for curent month i count :COUNT (distinct SabID)

its works

for previous month i count: COUNT({<StatusHistory.YearMonth = {"$(=StatusHistory.YearMonth(Max(StatusHistory.YearMonth), -1))"}>}distinct SabID)

but is not working

6 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Try this


COUNT({<StatusHistory.YearMonth = {"$(=Max(StatusHistory.YearMonth), -1)"}>}distinct SabID)

manojkulkarni
Partner - Specialist II
Partner - Specialist II

Better create a date using monthyear data available, then you can easily add a flag for current & previous month, year etc.

Not applicable
Author

not working..

alexandros17
Partner - Champion III
Partner - Champion III

Could you provide your example?

senpradip007
Specialist III
Specialist III

Hi,

In your Master Calendar if there is no year & month then create these two,

Load

MakeDate(Left(StatusHistory.YearMonth, 4), Right(StatusHistory.YearMonth,3)) AS Date,

Left(StatusHistory.YearMonth, 4) AS Year,

Num(Right(StatusHistory.YearMonth,3)) As Month

......

Then try this expression:

Count({<Year = {'$(=Max(Year))'}, Month={'$(=Max(Month))'}>} Distinct SabID) ---- Current Month

Count({<Year = {'$(=Max(Year))'}, Month={'$(=Max(Month) - 1)'}>} Distinct SabID) ---- Previous Month

Hope it helps.

Not applicable
Author

thanks all for replayes, i cant sent a example becouse its very huge (500mb), ist complicate to explain, but i have a master caledar, but i can use ir for his expresion, becouse its coresponds for abonement sales date..i need count all active abonemens  for each month, and for this i have field StatusHistory.YearMonth. Waht exacly i need:

i need on straight table have 2 expresions, one - active abonements on month start(i already have it with - COUNT (distinct SabID), second - active abonement on month end (for this i want to get values from next month, , becouse the values of next monthstart active abonemets ant curentmonthend is similar.