Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Last Full Month

Hi,

I am trying to run a report for last full month regardless of the date

For example if I run the report now I would like to retrieve May's data. It also needs to be dynamic.

Any help would be much appreciated

1 Solution

Accepted Solutions
varshavig12
Specialist
Specialist

Try this:

sum({<[Bill Date]={"<$(=MonthStart(today())) >=$(=MonthStart(addmonths(today(),-1))) "}, Month=  >} [Bill Value] )

View solution in original post

25 Replies
ciaran_mcgowan
Partner - Creator III
Partner - Creator III

Hi Dave,

Can you post a copy of your report as it exists now. Usually you would use AddMonths function to achieve this but if I can see what you're trying to accomplish, I might be able to help more.

AddMonths(Max(YourDate),-1)

Anonymous
Not applicable
Author

if you Need to run your Report with last months data you have two Options depending on your datamodel

1) you have field which contains full date Format (day, month, year)

  then you Need to run your Report with

  (yourdatefield >= monthstart(addmonths(today(),-1)) and (yourdatefield <= monthend(addmonths(today,-1))

2) if you have a month field and year field

    (youryearfield = year(addmonths(today(),-1)) and   (youmonthfield = month(addmonths(today(),-1))

Anonymous
Not applicable
Author

Hi Dave,

Make a variable with this code:

     If(YourDate = MonthEnd(YourDate),YourMonth,Month(Addmonths(YourDate),-1))

With this code you will test if current month is complete, if it is true you will get current month, else, you will get last complete month.

Select your report with this var.

Regards!!

juleshartley
Specialist
Specialist

you might need a 'floor' in this to be sure no time element causing issues...

if(YourDate=Floor(MonthEnd(YourDate)), Floor(MonthEnd(YourDate)), Floor(MonthEnd(AddMonths(YourDate,-1))))

Anonymous
Not applicable
Author

If the field is date format, and not is TimeStamp format, you don't need to use Floor function.

Regards.

Not applicable
Author

this errors after the and ay ideas?

Anonymous
Not applicable
Author

can you post sample?

susovan
Partner - Specialist
Partner - Specialist

Hi Dave,

Try this expression,

sum({<Date={">=$(vMonthStart)<=$(vMonthEnd)"},Month=,Quarter=,FullYear=>} Amount)

Here

vMonthStart=Date(MonthStart(Max(@_Date)),'DD/MM/YYYY')

vMonthEnd=Date(Max(@_Date),'DD/MM/YYYY')

Warm Regards,
Susovan
Not applicable
Author

Sum({<[Bill Date] {">= monthstart(addmonths(today(),-1)) and [Bill Date] <= monthend(addmonths(today(),-1))"} > [Bill Value])

I am trying to sum bill value by bill date