Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

wrong evaluation of a date expression

Hi,

I m trying to find the current month and the prcedent one

So for current month I worked with this expression and it done well : MonthName(Max(Month))

But for the Precedent Month this expression return a number  : (Max(Month)-1) =42095

and this one (= MonthName((Max(Month))-1)) return the same result as (MonthName(Max(Month))).

Help

8 Replies
sunny_talwar

Try this:

MonthName(AddMonths(Max(Month), -1))

Clever_Anjos
Employee
Employee

Try MonthName(Max(Month,2))

MarcoWedel

Hi,

that "MonthName(Max(Month))" is working for you means that "Month" holds date values.

Subtracting 1 from a date value again means subtracting one day, even if this field is called Month.

One solution might be to use the "shift" parameter of the MonthName() function to return the previous month:

MonthName(Max(Month),-1)


hope this helps


regards


Marco

Not applicable
Author

Thank you .

It work but return "Nov.2015"

Not applicable
Author

Thank you but it didn't return any result '-'

Not applicable
Author

Thank you

This solution work too but with the same problem as SunnyT's proposition it return the date like this 'Nov.2015' and I need only the month.

Not applicable
Author

I findet

I should like this write my expression : date((MonthName(Max(Month),-1)),'MM')

but  why this  MonthName(AddMonths(Max(Month), -1)) return the years too !

jonathandienst
Partner - Champion III
Partner - Champion III

Perhaps the expressions you need are
MonthName(Max(Month)) and MonthName(Max(Month), -1) to return year/month values, or


Month(Max(Month)) and Month(AddMonths(Max(Month), -1)) to return month only values

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein