Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
karvagear
Contributor
Contributor

Simple data range question

Hi guys,

 

i'm stucking ni this simple situation where i need ta have bars from a date range (2014-now) but not all date have data in them, how do i generate a local autogenareted table with a date range?

 

in Oracle i would do someting like this:

 

SELECT

(to_date(sysdate,'DD-MM-YYYY') - level + 1) AS day

FROM

dual

CONNECT BY LEVEL <= (to_date(sysdate,'DD-MM-YYYY') - to_date('01-01-2014','DD-MM-YYYY') + 1);

Labels (1)
2 Replies
PrashantSangle

Let vMinDate = Date(Date#('01-01-2014','DD-MM-YYYY'));

Let vMaxDate = Today();

Load

Date($(vMinDate) + IterNo() - 1)    as Date_Field

AutoGenerate 1

While $(vMinDate) + IterNo() - 1 <= $(vMaxDate);

 

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
sidhiq91
Specialist II
Specialist II

@karvagear  You can use the below script too.

Let Vmin = Date(Date#('01/01/2014','MM/DD/YYYY'));
Let Vmax= Today();

Trace >>>> $(Vmin);
Trace >>>> $(Vmax);

 

Temp:
Load

Num('$(Vmin)'+IterNo()-1) as Date_Num
AutoGenerate 1
while Num('$(Vmin)'+Iterno()-1)<=Num('$(Vmax)');

Date:
Load Date(Date_Num,'MM/DD/YYYY') as Date
Resident Temp;

Drop table Temp;

Exit Script;