Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

eduardo_dimperi
Valued Contributor II

Using FieldName in a Where Clause

Hi,

I've this situation

Input:

LOAD

//more fields before

'42990'

'42991'

'42992'

'42993'

'42994'

'42995'

'42996'

'42997'

'42998'

'42999'

//more fields after

FROM [lib://VisitaMI (bi_bi.desenvolvimento)/CONTROLE - AGENDAMENTO -2016-2017-2018 V012.xlsx]

(ooxml, embedded labels, table is Geral);

This came from a Excel file where each field is a date.

How can i select only the field where field's name ate equal today? (42998)

I thought something like :

LOAD

*

FROM [lib://VisitaMI (bi_bi.desenvolvimento)/CONTROLE - AGENDAMENTO -2016-2017-2018 V012.xlsx]

(ooxml, embedded labels, table is Geral)

WHERE FieldName() = Num(Today());

Any Help Please

1 Solution

Accepted Solutions
MVP
MVP

Re: Using FieldName in a Where Clause

Maybe like this

Let vField = Num(Today(1));

LOAD

    //more fields before

   "$(vField)",

   //more fields after

FROM ...; // NO WHERE CLAUSE

8 Replies
Employee
Employee

Re: Using FieldName in a Where Clause

It´s not possible, you have to use the correct field name

One alternative is cross table your excel file and then filter the results

MVP
MVP

Re: Using FieldName in a Where Clause

Maybe like this

Let vField = Num(Today(1));

LOAD

    //more fields before

   "$(vField)",

   //more fields after

FROM ...; // NO WHERE CLAUSE

eduardo_dimperi
Valued Contributor II

Re: Using FieldName in a Where Clause

Hi ,

Just to Know i solve using crosstable, that way i could create a Field named "Data" with all field's name on it and filter

Teste:

Crosstable (Data, Visita)

LOAD

*

FROM [lib://VisitaMI (bi_bi.desenvolvimento)/CONTROLE - AGENDAMENTO -2016-2017-2018 V012.xlsx]

(ooxml, embedded labels, table is Geral);

NoConcatenate

Teste2:

Load

*

resident Teste

WHERE Data=Num(Today());

drop table Teste;

exit script;

Highlighted
eduardo_dimperi
Valued Contributor II

Re: Using FieldName in a Where Clause

Hi Clever,

I used crosstable on my script, cause other person where use this excel file

Valeu.

vvira1316
Valued Contributor II

Re: Using FieldName in a Where Clause

Hi,

Will you be able to share a sample data set. It can be limited records with this field and may be some other fields. That will help to guide you.

BR,

Vijay

eduardo_dimperi
Valued Contributor II

Re: Using FieldName in a Where Clause

Hi Stefan, always helping us

I think using crosstable apears to be easier to work with, nevertheless your answer works just fine

Thank you

eduardo_dimperi
Valued Contributor II

Re: Using FieldName in a Where Clause

Hi Vijay !

Thank you for your time, but i already solve with crosstable and Stefan's answer works very weel too.

MVP
MVP

Re: Using FieldName in a Where Clause

You are welcome.

Might be a good idea to alias the field, so you don't have to change the script / expressions:

  "$(vField)" as TodaysField,

Community Browser