Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

use of FieldValueCount(getting 1 row more than the number of rows)

Hi all,

I Used  FieldValueCount function to count the number of rows of a field  in a column, in detail to count the number of rows in each column of my table.

http://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/CounterFunctions/fieldv...

My problem is, i am getting one row more than the rows of that i have in each column

can anyone help me with this/.. How a FieldValueCount function works

Thanks

Ganesh

1 Solution

Accepted Solutions
antoniotiman
Master III
Master III

NoConcatenate

  FactGetPOChangeTime:

  LOAD

  TagsForPOTime,

  if(TagsForPOTime='Fill A',POTime,0) as FillATime,

  if(TagsForPOTime='Fill A',1,0) as CountA,

  if(TagsForPOTime='Fill B',POTime,0) as FillBTime,

  if(TagsForPOTime='Fill C',POTime,0) as FillCTime

  Resident GetPOChangeTime;

TotalCount:

Load

Sum(CountA) as TotalCountA

Resident FactGetPOChangeTime:

Let vRowsFilATIme = Peek('TotalCountA');

Drop Table TotalCount;

View solution in original post

25 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

FieldValueCount is a function that directly uses in-memory system tables. Because of this it does not take selections, chart dimensions and expressions into account. Try using the Count function instead. Perhaps Count(distinct total MyField) does what you want.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert

Yes, I want to count the number of values of a row in a table which is acquired by using Resident Table. so, i am using that for in-memory table only i suppose.  I am taking the result of fieldvaluecount function into a variable using let

I mean

Let vNoofrows=fieldvaluecount('fieldname');

I am not using any selections or any chart

I am just interested in counting the number of rows for each field in a table..

I am getting the exactly one value more than the number of rows in each column.. is it also counting the column name??

Thank you

Ganesh

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

FieldValueCount will give you the total number of distinct values of a field over all tables. You can't make it tell you the number of distinct values of a field from only one table if the fields exists in multiple tables.


talk is cheap, supply exceeds demand
Not applicable
Author

yeah, even i thought  of possibility of giving table name in  fieldvaluecount function .

could you please tell me, how to count the number of rows in a table, i am getting syntax error when i try like this

let vrowcount=count(fieldname);

and I want to count all the rows in a field, i dont want to use distinct

Thanks

Ganesh

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

If you only want the number of rows of a table instead of the number of unique values of a field in a table then use the NoOfRows() function. That function accepts a table name as parameter.


talk is cheap, supply exceeds demand
Not applicable
Author

sorry.. i want number of rows in each field

NoConcatenate

  FactGetPOChangeTime:

  LOAD

  TagsForPOTime,

  if(TagsForPOTime='Fill A',POTime,0) as FillATime,

  if(TagsForPOTime='Fill B',POTime,0) as FillBTime,

  if(TagsForPOTime='Fill C',POTime,0) as FillCTime

  Resident GetPOChangeTime;

I  want to count the number of rows for each fields FillATime. FillB ime, FillCTime

like

let vRowcountFilATIme = count(FillATime);

like this i want to store the row count in a variable, to use that further in my code

Thank you

Ganesh

MayilVahanan

Hi

Try like this

Temp:

Load Count(FillATime)  AS FATime, Count(FillBTime) As FBTime, Count(FillCTime) AS FCTime resident FactGetPOChangeTime;

Let vRowcountFilATIme = Peek('FATime');

Let vRowcountFilBTIme = Peek('FBTime');

Let vRowcountFilCTIme = Peek('FCTime');

Drop Table Temp;

Hope this helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Each row of a table will contain all the fields. So the count of rows for each field is the count of rows of the table.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Mayil

I tried this way, but , I am getting the result of first column for other columns also.. i dont know why

I mean NoOfRows for FillATime is also coming for other columns