Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Magogar
Contributor III
Contributor III

Sum operations of the last month

 

Hello 🙂

I need to 'sum' the operations of the last month, from a range of several years.

Example: from a range from August 2021 to today, only August 2022

 

fecha ops
03/08/2021 2
03/07/2022 6
04/08/2022 10
09/08/2022 12

 

It is similar to this but with month:

=Sum({<[fecha.autoCalendar.Year]={"$(=Year(max([fecha])))"},>} ops)

How can I add those operations?

Thank you!!!

Labels (1)
1 Solution

Accepted Solutions
BrunPierre
Partner - Master
Partner - Master

2022 is the current year or perhaps from your model is it last year?  if it's the former then the below expression is for the current year (2022) and the previous month (July).

=Sum({<[fecha.autoCalendar.Year]={"$(=Year(max([fecha])))"},[fecha.autoCalendar.Month]={$(=month(addmonths((max([fecha])),-1)))} >} ops)

View solution in original post

5 Replies
BrunPierre
Partner - Master
Partner - Master

Try this

=Sum({<[fecha.autoCalendar.Month]={$(=month(addmonths((max([fecha])),-1)))} >} ops)

Magogar
Contributor III
Contributor III
Author

Hello @BrunPierre 

 

Magogar_0-1660212890927.png

Maybe I haven't expressed it well. With this sentence it shows the previous month of all the years. But I need it to show  is the last month (July), of the last year(2022).

Magogar_2-1660213181643.png

Thank you!

 

BrunPierre
Partner - Master
Partner - Master

2022 is the current year or perhaps from your model is it last year?  if it's the former then the below expression is for the current year (2022) and the previous month (July).

=Sum({<[fecha.autoCalendar.Year]={"$(=Year(max([fecha])))"},[fecha.autoCalendar.Month]={$(=month(addmonths((max([fecha])),-1)))} >} ops)

Magogar
Contributor III
Contributor III
Author

It works, thank you!!!!!!!!!

I have made a small adjustment:

Sum({<[fecha.autoCalendar.Year]={"$(=Year(max([fecha])))"},[fecha.autoCalendar.Month]={"$(=month((max([fecha]))))"}>}ops)

BrunPierre
Partner - Master
Partner - Master

Yes, I realised and edited, anyways happy to help!