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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
kev6brown
Partner - Creator II
Partner - Creator II

Max Month minus 1

Hi,

 

I have the expression - Count({<ADMIT_MNTH = {"$(=Max(ADMIT_MNTH))"}>}[Patient]) which gives me the max month but i know need the same expression but the previous month so MINUS 1

 

Thanks

 

Kev

Labels (1)
7 Replies
dplr-rn
Partner - Master III
Partner - Master III

use addmonths function with -1

Count({<ADMIT_MNTH = {"$(=AddMonths(Max(ADMIT_MNTH),-1))"}>}[Patient])

 

kev6brown
Partner - Creator II
Partner - Creator II
Author

Comes through as zeros
dplr-rn
Partner - Master III
Partner - Master III

check output of this expression in a text object and check

 

AddMonths(Max(ADMIT_MNTH),-1)

Kushal_Chawda

try below

assuming ADMIT_MNTH format is MMM YYYY.  In below set you can try giving actual format

Count({<ADMIT_MNTH = {"$(=date(addmonths(Max(ADMIT_MNTH),-1),'MMM YYYY'))"}>}[Patient])

kev6brown
Partner - Creator II
Partner - Creator II
Author

That gives me the previous month but in the format 01/06/2020 maybe that's why
dplr-rn
Partner - Master III
Partner - Master III

@kev6brown wrap it with date and try

 

Ke_Sg
Contributor II
Contributor II

Hi,

I know this is an old thread (well, this thread is the first on Google 😃), but I had a kinda-similar problem, when I had to lookup the value before highest value.

If you use

max([Field]) 

you obviously get highest value of [Field]. With this value, you can do simple maths, like max()-1 or "add" -1 day, month ... to a date. But if the value before the highest is not guessable, you can use the second parameter of max() function :

max([Field], 2)

This will return the value before the highest, in both Qlikview and Qliksense. A similar parameter also exists for min().

https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/ChartFunctions/Ba... 

 

In that case, this should do the trick :

Count({<ADMIT_MNTH = {"$(=Max(ADMIT_MNTH, 2))"}>}[Patient])