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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
eladzbir
Contributor
Contributor

HEY

hey

 

i want to change this line:

vPreMonthQLIK= MonthStart(AddMonths(Today()-1,-2));

 

to

if your calander month is january pick december (with numbers), else current month minus 1

 

thank you

 

elad

Labels (2)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

Try this

Month(AddMonths(Today(),-1))

Or this if you want to present the number 

Num(Month(AddMonths(Today(),-1)))

View solution in original post

3 Replies
Vegar
MVP
MVP

Try this

Month(AddMonths(Today(),-1))

Or this if you want to present the number 

Num(Month(AddMonths(Today(),-1)))

eladzbir
Contributor
Contributor
Author

Thank You
sidhiq91
Specialist II
Specialist II

@eladzbir  Please see the code below:

NoConcatenate
Temp:
Load Date,
sales,
Month(Date) as Month;

load date(Date#(Date,'MM/DD/YYYY'),'MM/DD/YYYY') as Date,
sales
inline [
Date, sales
01/11/2023,10
04/14/2023,12
07/23/2023,13
08/22/2023,14
12/24/2022,15
];

Let VDec=Month(Yearend(Today(),-1));

Exit Script;

In the front end: for Dimension field use the below expression:

=Aggr(if(GetFieldSelections(Month)='Jan','$(VDec)',Max(Month)-2),Month)

Please let me know if this has resolved the issue.