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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
KPage
Contributor III
Contributor III

Creating a "Date" dimension

Hi,

I would like to create a "Date" dimension that only uses the current year and the prior year. Right now, I have data from 4 years ago. "Date" is already a dimension on my report, but is there a formula I can use so that a separate "Date" dimension only pulls CY and PY?

 

Thank you

Labels (3)
3 Replies
Antoine04
Partner - Creator III
Partner - Creator III

Hello,

In your script, you can do something like :

Calendar:

Load Distinct Year(Date) as Year

Resident YourTable

Where Year(Date)>=Year(today())-1;

brunobertels
Master
Master

Hi 

Add this in your script 

=if(year(Date)>year(addyears(today(),-2)) ,Date) as DATE_CY&PY

PhanThanhSon
Creator II
Creator II

Hi @KPage,

try this:

Load *,
IF(Year = year(today()) OR Year = year(today())-1, Year, Null()) AS CY_PY    
    Inline [
Year
2024
2023
2022
2021
];

You can also use Set Analysis depends what your looking for.

PhanThanhSon_0-1708618358422.png