Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

howmany rows in a table

I think it should not be that difficult, but somehow I can't find the answer.

We have a straight table containing ofcourse data ;-), now we want to show the number of rows of that table in the header of the table.

How to do stuff in the header is not the problem, but how to get the number of rows displayed??

Anyone knows how to get the number of rows in the table??

In the development environment the number of rows is displayed in the bottom of the screen when selecting the table . . . but in de accesspoint environment ofcourse this is not available . . .

Is there a function to get this?

NoOfRows() gives just the number 1

9 Replies
Not applicable
Author

Hi Anita:

Hope the attached App would help you.

Thanks,

Narasimha K

Not applicable
Author

Hi Anita,

did you try with =count(<field_from_table>) ?

regards

Anonymous
Not applicable
Author

The count function will not do the trick I guesse.

The straight table contains data combined from more data-tables which could give more rows than the original table has.

If I count(<field>) this gives only the number of fields for the table the field belongs to, not the physical number of rows the straight table has.

Not applicable
Author

Attached is the macro snippet to fetch the number of Physical rows from a Straight Table.

Sub NoofRows

  set table = ActiveDocument.GetSheetObject("CH01")
  rows =  table.GetRowCount - 1
  msgbox "Number of Rows in Straight table is " & rows

End Sub

Hope that helps...

Not applicable
Author

In that case you should use set analysis with system attributes:

=sum({$<$Table={'<table_name>'}, $Field={'field_name'}>} $Rows)

regards

Not applicable
Author

I had the same problem

simply use count(name of your first dimension)

In my case I give the label "Document" to the first dimension of my straight table and in the window title I added

=' Total rows : ' & Count(distinct(Document))

Teppo_Ojala
Former Employee
Former Employee

Hi,

I had the same challengr in one of my projects. I managed to write quite nice function to calculate number of expected rows in straight table.

My function is:

sum(aggr(1, <dim1>,<dim2>, <dim3> etc))

I have used QV11 functionality to hide/show fields chosen from basic listbox. Let's call the field by name "dimension_fields" - I have written a inline load to script that writes about 10 possible dimension to be used as columns in straight table.

Then I wrote a variable, for example v_chosen_dimensions and formula is

concat(dimension_fields, ',')

This variable has a value dim1,dim2 - if user has selected these 2 columns to be visible in straght table.

And then I changed my function to

sum(aggr(1,$(v_chosen_dimensions)))

I used this formula in "conditional show" to hide the straight table if amount of expected rows are greater than 300.

Hopefully I wrote all formulas correct way and hopefully this works in other cases also

Not applicable
Author

Hi,

Did you figure out a way to do this? I am trying to achive this and none of the recomendations really helped. Appreciate if you can help me if you figured out a way to get the physical number of rows.

Thanks.

frankhuning
Contributor III
Contributor III

Based on Narasimha function, I  use this:

Sub NoRowsInChart
set table = ActiveDocument.GetSheetObject("CH107")
rows = table.GetRowCount - 1
set v = ActiveDocument.Variables("vNrRows")
v.SetContent rows, true
End Sub

Where vNrRows is the name of my variable.

This Macro will be submitted by activating the sheet/chart through a trigger. In my chart header text I use the variable vNrRows


Regards Frank