Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Problem with Fieldvalue() function

Hello

I want to extract the minimum date of one table (the dates are decimal fields in the DB) and use it fo make a for loop.

What I have done was:

TempMin:

  LOAD *;

  SQL

  SELECT min($(Date_Field)) as minDate

  FROM $(Table_Name)

  WHERE $(Company_Name) = $(company);

  let varMinMonth = FieldValue('minDate',1);

And I have always a null value in the varMinMonth variable, but when I put the field minDate in a TableBox it shows the correct value.

If I ceate one inline table, the result is OK

LOAD * INLINE [

English, German

Hello, Hallo

This is a test, Dies ist ein Test

];

let a =FieldValue('English',1);

Anyone can help me on this?

Thnak you

12 Replies
swuehl
MVP
MVP

Not exactely sure what causes your issue.

Could you maybe create a small sample QVW and post it to this thread?

(just your short script that loads the data and the variable, with the script executed, so we can look at your table and values)

I usually use the Peek() function to address table values:

let varMinMonth = Peek('minDate',0, 'TempMin');

Anonymous
Not applicable
Author

Hello Swuehl

In the thread I dont have the option to attach files others than pictures or videos. I have creted a small QVD and loadded it using the script bellow.

TempMin:

  LOAD max(OKRGDT)

  FROM $(qvdFile)(qvd);

  let varMinMonth = FieldValue('minDate',1);

 

Test:

  LOAD * INLINE [

  English, German

  Hello, Hallo

  This is a test, Dies ist ein Test

  ];

let a =FieldValue('English',1);

As you can see bellow the variable is varMinMonth = null.


QV.PNG


Bellow an example of the data in the QVD file. It is a decimal field that represents a date.

20100927

20101227

20101228

20101229

20101230

20110107

20110110

20110111

20110112

20110117

20110119

20110120

20110223

20110228

swuehl
MVP
MVP

You can attach files in the 'advanced editor' in the forum, please follow

Uploading a Sample

Please post the sample QVD.

trdandamudi
Master II
Master II

FieldValue function will only work with distinct field values. So as Stefan suggested please use:


let varMinMonth = Peek('minDate',0, 'TempMin');


Hope this helps...


oscar_ortiz
Partner - Specialist
Partner - Specialist

Where are you defining the "minDate" field.  The FieldValue() function will fail silently if your field does not exist.

Did you possibly mean to do this?

TempMin:

  LOAD max(OKRGDT) as minDate

  FROM $(qvdFile)(qvd);

  let varMinMonth = FieldValue('minDate',1);

Anonymous
Not applicable
Author

Hello Guys

Thank you for your help, I have been able to discover that If I load the data from a QVD file:

TempMin:

LOAD OKRGDT as minDate

FROM $(qvdFile)(qvd);

let varMinMonth = FieldValue('minDate',1);

let varMinMonth2 = Peek('minDate',0, 'TempMin');


Everything works fine.



But if I load the data directly from the database:

TempMin:

  LOAD *;

  SQL

  SELECT min(OKRGDT) as minDate

  FROM OCUSMA

  WHERE OKCONO = 200;

  let varMinMonth = FieldValue('minDate',1);

  let varMinMonth2 = Peek('minDate',0, 'TempMin');

  let varMinMonth1 = FieldValue('MINDATE',1);


I works only when I use MINDATE in uppercase. I can work with it, but any idea why?

Thank you for your help

Felipe

swuehl
MVP
MVP

Felipe, which field name spelling is actually shown in the table view?

This should be the correct spelling when addressing the field using QlikView functions.

marcus_sommer

One reason for this behaviour could be that fieldvalue() only grabbed the numeric value and not provide a string-interpretation like in this case: Re: Problem with FieldValue. Therefore try something like:

let varMinMonth = date(num(FieldValue('minDate',1)));

     or maybe

let varMinMonth = dual(date(FieldValue('minDate',1)), num(FieldValue('minDate',1)));

- Marcus

Anonymous
Not applicable
Author

Hi

In teh table view the name of the filed is MINDATE instead of minDate