Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

Add a month in set expression

Hi experts

I have this formula to calculate one month after January, in our case: 01.02.2023 - 28.02.2023

{<[YearMonth]={"$(='>=' & yearstart(MonthStart(Addmonths(max(YearMonth),+1))) & '<=' & MonthEnd(yearstart(Max(YearMonth), +1)))"}>}

It is not showing the right month. Where is the error.

Thanks for your help!

Labels (5)
7 Replies
ckarras22
Partner - Creator
Partner - Creator

Hello

 

Could you please use the below

 

{<[YearMonth]={">=$(=yearstart(MonthStart(Addmonths(max(YearMonth),+1))))<=$(=MonthEnd(yearstart(Max(YearMonth), +1)))"}>}

 

 

Parthiban
Creator
Creator

Try This one...

One month after January  Start  =  Date(YearStart(Today(),0,2),'DD/MM/YYYY')

One month after January  End  =    Date(MonthEnd(YearStart(today(),0,2)),'DD/MM/YYYY')

 

Instead of Today, use YearMonth field.

Check this formula in your case. If this is not working let we check any other possibilities.

Selvapriya_Thevar
Contributor II
Contributor II

@TomBond77  Hi 

Kindly try this 

{<[YearMonth]={">=$(=yearstart(MonthStart(Addmonths(max([YearMonth]),+1)))<=$(=MonthEnd(yearstart(Max([YearMonth]),+1))))"}>}

Ahidhar
Creator III
Creator III

Would be better to write it with some aggregate function

panosalexand
Creator
Creator

Hi, may I ask you to clarify?  Would you like when you select January the calculation will be one month after?

Ahidhar
Creator III
Creator III

Yes ,  we get values for next month . Take below table for example 

try this in front end and we will get values for next month

Sum({<Yearmonth={"$(=monthname(Yearmonth,1))"}>}Value)

tab:
load *,
monthname(Date) as Yearmonth;
load * Inline
[Grp,Date,Value
Fed,02/1/2023,1000
Zed,14/01/2023,2000
Fed,27/01/2023,15000
Fed,02/02/2023,3000
Fed,04/02/2023,3500
Zed,15/02/2023,1200
Fed,03/03/2023,1523
Zed,13/03/2023,5000
];

 

panosalexand
Creator
Creator

I have done something similar for one of my projects.  But in my case, it was in the back end.

So this is what I did:

rename table XXXX to DataTemp;
Data:
Load *;
For i=0 to 1
Load Distinct Months ,

AddMonths(MonthStart(Months), $(i))+1 as PlusOneMonth,


Resident DataTemp;
Next i;


rename table Data to XXXX ;