Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

vidyasagar159
Contributor

Distinct Year from Date column or Year in for each loop to current date

Hi,

I want to create a Year drop down in my QLIK SENSE report. I got two options

1. In my QVD I have a Date column called "Period". Now I want to select only Distinct Year from that column. But I am not able find the right logic. This is what I wrote but the out put count is showing 1million records.

YearTable:

LOAD

    distinct year(PERDT)as "Year"

FROM [lib://GPG_QVD/BrightScope\SI_AUM_GlobalFunds.qvd]

(qvd);

2. Or I want to create a for each loop in a inline table from the year 2006 to current year.

Example: for (i=2006, i<=year(timestamp),i++){}

Can some one please guide me in the right direction.

Thanks,

-Vidya

1 Reply
jwjackso
Contributor III

Re: Distinct Year from Date column or Year in for each loop to current date

I tested your first script on a small data set and it returns 1 record for each year.  I would verify that the PERDT field is formatted correctly as a date or timestamp.

https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/DateAndTimeFun...

Community Browser