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

Announcements
Join us at Qlik Connect 2026 in Orlando, April 13–15: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
ananth
Contributor
Contributor

Setting Date variables

I want to create two date variables. First one, which is the maximum date based on a condition location=Dallas and another variable which is 12 months before the max date. How do I do it on this?

Labels (1)
1 Solution

Accepted Solutions
robert_mika

In script: 

Temp_MaxDate:
LOAD
Max(DateField) as MaxDate
RESIDENT (YourExistingTable)
WHERE Location = 'Dallas';


LET vMaxDateDallas = Peek('MaxDate', 0, 'Temp_MaxDate');


LET v12MonthsBefore = MonthStart(AddMonths(vMaxDateDallas, -12));

View solution in original post

2 Replies
robert_mika

In script: 

Temp_MaxDate:
LOAD
Max(DateField) as MaxDate
RESIDENT (YourExistingTable)
WHERE Location = 'Dallas';


LET vMaxDateDallas = Peek('MaxDate', 0, 'Temp_MaxDate');


LET v12MonthsBefore = MonthStart(AddMonths(vMaxDateDallas, -12));

Vegar
MVP
MVP

=dayname(Max({1<Location={'Dallas'}>} DateField))

 

=addyears(Max({1<Location={'Dallas'}>} DateField),-12)