Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

joeybird
Contributor II

loading data with filter from SQL

Hiya

i need to load data with filter from SQL into qlik sense

i need to load data from a specific date range only

e.g from 2005 to present

i have found on forum how to do this for txt file (but i need to do this for SQL) ... but only for between to dates. but i need 2005 to present

Loading data with filter on date 

please help

Kind Regards

Joeybird

1 Solution

Accepted Solutions
MVP
MVP

Re: loading data with filter from SQL

try

let vstart='20150101';

let vend=date(Today(), 'YYYYMMD');

LOAD *;

SQL SELECT *

FROM somesqlservertable

where dat_data >= '$(vstart)' and dat_data <= '$(vend)'

;

6 Replies
MVP
MVP

Re: loading data with filter from SQL

try

let vstart='20150101';

let vend=date(Today(), 'YYYYMMD');

LOAD *;

SQL SELECT *

FROM somesqlservertable

where dat_data >= '$(vstart)' and dat_data <= '$(vend)'

;

Not applicable

Re: loading data with filter from SQL

Hi,

Here's some examples :

Oracle : WHERE MyDate BETWEEN TO_DATE('01/01/2005','mm/dd/yyyy') AND SYSDATE

Sql Server 2012 : WHERE MyDate >= CAST('01/01/2005' AS DATE) AND MyDate <= GETDATE()

Xavier.

joeybird
Contributor II

Re: loading data with filter from SQL

Hiya

this worked fab, but would like to as well only 2005 load e.g certain departments data criteria too from SQL?

I have this to get my drop down

if(Wildmatch([DepartmentCode], '*999'), [Department]) as [Department],

how would I use this to only load in certain department data too?

Kind Regards

Joeybird

joeybird
Contributor II

Re: loading data with filter from SQL


Hiya

I meant to say

if(Wildmatch([DepartmentCode], '*999'), [Department]) as [DepartmentDropDown],

please help

Kind Regards

Joeybird

MVP
MVP

Re: loading data with filter from SQL

filter in Qlik

LOAD *

where wildmatch([DepartmentCode], '*999')

;

SQL SELECT *

FROM somesqlservertable

where dat_data >= '$(vstart)' and dat_data <= '$(vend)'

;



filter in Sql

LOAD *

;

SQL SELECT *

FROM somesqlservertable

where dat_data >= '$(vstart)' and dat_data <= '$(vend)'

and departmentcode like '%999'

;

joeybird
Contributor II

Re: loading data with filter from SQL

Hiya

A *** brill xx

thank you

Kind Regards

Joeybird