Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Ayden
Contributor III
Contributor III

year end variable

hello all, I am trying to create a date variable for the end of the year.

what i am trying to achieve is to use that end of year variable to filter my date field in my table to only retrieve data from current month till end of the year.

table:

load

aaaa,

bbbb,

datefield,

cccc

from cuz

where datefield <=variable;

 

need to get data for current month till end of the year.

 

 thanks All.

Labels (4)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

 

As below

Let vCurrMonth = Date(MonthStart(today()),'YYY-MM-DD');

Let vYearEnd=

Date(YearEnd(today()),'YYY-MM-DD');

 

 

Load *

From yoursourcetable 

Where DateField >='$(vCurrMonth)' AND DateField <='$(vYearEnd)'

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

2 Replies
Andrei_Cusnir
Specialist
Specialist

Hello,

 

Perhaps you can do something like this:

 

let vEndYear = MonthEnd(MakeDate(Year(Today()), 12, 1));
Trace End of year: $(vEndYear);

 

 

Allow me to elaborate in detail:

  1. Year(Today()) will give you the 2022 value
  2. MakeDate(Year(Today()), 12, 1) will give you the date which points to the first day of the last month of the year
  3. MonthEnd()  will use the new date to return the last day of that month

 

The output is:

I hope that this information was helpful. In case I have misunderstood the use case scenario, please elaborate in details by providing additional information. However, if it has helped you resolve the issue, please mark it as accepted solution to give further visibility to other community members. 
 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂
vinieme12
Champion III
Champion III

 

As below

Let vCurrMonth = Date(MonthStart(today()),'YYY-MM-DD');

Let vYearEnd=

Date(YearEnd(today()),'YYY-MM-DD');

 

 

Load *

From yoursourcetable 

Where DateField >='$(vCurrMonth)' AND DateField <='$(vYearEnd)'

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.