Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

eduardo_dimperi
Valued Contributor II

Working with variables

Hey people,

I need some help, i think will be a silly question cause its very simple to workaround, but i want to learn so i have this 2 codes:

LET vDataCarga_ini=date(today(), 'YYYYMM');

LOAD

*

FROM

[lib://MI_csv/CONSUMO_ELEVADO_DIARIO_$(vDataCarga_ini).qvd](qvd)

WHERE $(vDataCarga_ini)??>(TODAY()-5);

************

CONCAT_TABLE:

LOAD

*

FROM [lib://MI_csv/RS_INDIVIDUAL_READ_*.qvd]

(qvd) where DATE_READ>TODAY()-2;

If i chance code two to

FROM [lib://MI_csv/RS_INDIVIDUAL_READ_??.qvd]

It works fine

So, why i can't do this in code one?

[lib://MI_csv/CONSUMO_ELEVADO_DIARIO_$(vDataCarga_ini)??.qvd](qvd)

1 Solution

Accepted Solutions

Re: Working with variables

This should work, I think

[lib://MI_csv/RS_INDIVIDUAL_READ_$(vDataCarga_ini)??.qvd](qvd)

10 Replies

Re: Working with variables

How does the qvd filename look like? Can you share one of the names?

eduardo_dimperi
Valued Contributor II

Re: Working with variables

Off Course

I make a qvd daily, so i have:

RS_INDIVIDUAL_READ_20170101.qvd

RS_INDIVIDUAL_READ_20170102.qvd

RS_INDIVIDUAL_READ_20170103.qvd

RS_INDIVIDUAL_READ_20170104.qvd

RS_INDIVIDUAL_READ_20170105.qvd


and goes

Re: Working with variables

These are different qvd then this

[lib://MI_csv/CONSUMO_ELEVADO_DIARIO_$(vDataCarga_ini)??.qvd](qvd)

Re: Working with variables

This should work, I think

[lib://MI_csv/RS_INDIVIDUAL_READ_$(vDataCarga_ini)??.qvd](qvd)

eduardo_dimperi
Valued Contributor II

Re: Working with variables

Humm i found the problem, your code works very good but its in WHERE clause that thing goes wrong.

First problem, i need to change WHERE $(vDataCarga_ini)??>(TODAY()-5); to WHERE $(vDataCarga_ini)&'??'>(TODAY()-5);

and second I cant use a variable to filter, cause it doesn't part of the tables, for that reason i get no data.

Thank you Sunny

Re: Working with variables

May be this:

Where Date#(SubField(FileBaseName(), '_', -1), 'YYYYMMDD') > Today() - 5;

eduardo_dimperi
Valued Contributor II

Re: Working with variables

Wow, It works too !

the only strange thing, its when i try order by, not work

LOAD

*

FROM

[lib://MI_csv/CONSUMO_ELEVADO_DIARIO_$(vDataCarga_ini)??.qvd](qvd)

Where Date#(SubField(FileBaseName(), '_', -1), 'YYYYMMDD') > Today() - 5

ORDER BY DATA_DEFEITO;

Re: Working with variables

You cannot use Order by in a qvd, Excel or any other type of file load..... It only works when you do it on a Resident load

Can you use 'Order By' in a QVD Load?

Re: Working with variables

Also look here:Load ‒ QlikView

Capture.PNG