2 Replies Latest reply: May 9, 2018 8:08 AM by Mazen Bilto

# In a set analysis, getting a month and the month before it.

Hello qlik community

I have a problem that im suffering with and a senior of mine before me that struggled with it too. Currently on the April version im trying to do this in a set analysis

Keep in mind that i have constructed a dat to look like this: if this was a date "3/25/2018 10:10:10 AM" it turns it to "3/2018" so only the month and the year

KPI 1 (On this KPI i want to show the latest year and month in the data)

some im writing something like this

Count( {\$<Month_Year = {'\$(=Max(Month_year))'}>} ID) ----> this works

KPI 2 (On this KPI i want to show the year and month prior to the selection in KPI 1)

and for this one i try this

Count( {\$<Month_Year = {'\$(=Max(Month_year) -1)'}>} ID) -----> this doesnt work

Count( {\$<Month_Year = {'\$(=AddMonths(Max(Month_year), -1) )'}>} ID)  -----> this doesnt work either

also any kind of month manipulation just doesnt work in set analysis. Note that these operations work in a Text/Image Chart and i verified that it can work. but in set analysis it doesnt.

Thank you

• ###### Re: In a set analysis, getting a month and the month before it.

If you create Month_Year like this in the script

Date(MonthStart(date), 'M/YYYY') as Month_Year

then try this

Count( {\$<Month_Year = {"\$(=Date(AddMonths(Max(Month_year), -1), 'M/YYYY'))"}>} ID)

Basically, you need to make sure that format within your set analysis matches with the format of your Month_Year field.

• ###### Re: In a set analysis, getting a month and the month before it.

Thank you so very much!