5 Replies Latest reply: Sep 27, 2016 5:01 AM by Varsha Vig

# Max month minus 1

Hi The expression below is giving me the max YearMonth but I cannot get it to work for the Max YearMonth -1

Any help appreciated

if(isnull(num((((Avg({\$<HRPrimaryCare={7},ReferredYYYY,YearMonth={"=\$(#=Max({<[HRPrimaryCare]={7}>}YearMonth))"}>}ActualValue)))), vNumber)),Null(),

num((((sum({\$<HRPrimaryCare={7},ReferredYYYY,YearMonth={"=\$(#=Max({<[HRPrimaryCare]={7}>}YearMonth))"}>}ActualValue)))), vNumber))

• ###### Re: Max month minus 1

What is the YearMonth format? 201606 for example?

• ###### Re: Max month minus 1

it is made by the text below in the script and is YYYY,MM

MonthName(Date(makedate(ReferredYYYY,ReferredMM))) as YearMonth,

• ###### Re: Max month minus 1

I recommend you to create Variable for that

For prev month you can try this too

if(isnull(num((((Avg({\$<HRPrimaryCare={7},ReferredYYYY,YearMonth={"=\$(#=Max({<[HRPrimaryCare]={7}>}YearMonth)-1)"}>}ActualValue)))), vNumber)),Null(),

num((((sum({\$<HRPrimaryCare={7},ReferredYYYY,YearMonth={"=\$(#=Max({<[HRPrimaryCare]={7}>}YearMonth)-1)"}>}ActualValue)))), vNumber))

OR

Note: AddMonth(Expression, -1) will gives the previous month Data. If not, better to offer you logic if you shared the application