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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out 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
MVP
MVP

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
MVP
MVP

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)