Skip to main content
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
Showing results for 
Search instead for 
Did you mean: 

Row Count Macros not working in Straight table


I have created a macro which will count the number of rows in the straight table. 
But when the straight table is having "calculation condition"  feature set, this macro won't give the proper result.
When I remove the  "calculation condition" feature,  macro is working fine.

  Straight table without condition : Macros used in Caption giving the right count : 50336Without 50k rows &31 column condition.png

Straight Table condition:

calculation Condition.png

After  selecting rows greater than 50k with the condition : Here Macro still works fine at caption showing 50336

50k rows &31 column condition .png

After performing the above step, now If I select something which has less than 50k records macros gets updated to 150k rows &31 column 2.png

This occurs only when the condition is applied.
Can anyone help me with this? 

8 Replies

Why do you need a macro to do this calculation?


Hi Sunny,

Since the column selection is dynamic, I need to calculate row count every time any column is selected or deselected and multiple tables are involved here hence not able to consider the primary key column to the count.


I have a feeling that this can be done without a macro, but I won't really know unless I see it


I agree with Sunny that there might be other solutions than a macro to get this count, maybe with an approach like the following:

count(distinct $(='[' & concat(DimensionsListbox, ']&[') & ']'))

It exact logic and syntax depends on the way how the dynamic approach is implemented but because of the fact that the user-selection of those selections/variables is used to control the visibility and calculations in the object - they could be also used to calculate the number of rows in it.

- Marcus


Please find below one of the scenarios for which row count is calculated.


And my requirement involves multiple columns and tables.
There are many such scenarios involved with multiple tables and to calculate row count on any primary key is complicated.




I don't think you need macro here.  But calculation will really depend on your dimension and expression. In your above example what is expression?


Do you have multiple tables or do you have one table where you dynamically allow your users to select dimension? If it is later, then do you allow this using a list box to pick dimensions? All we need to understand is your setup... because essentially you can create a Sum(Aggr(Count()...)) function based on selection of your list box to figure out which dimensions do you have and use them in Aggr() function.

Former Employee
Former Employee

So I want to say I agree with the other posters on this one, macros should be the last resort when doing things in QlikView, and it seems they have some other ways of doing things, so my advice would be to follow up on those and see if one of them will work or provide the additional info they requested to try to help you further.  If you really want to stick with the macro, the issue here is going to be one of timing, and you are going to need to use the WaitForIdle API call at the start of the macro most likely in order to ensure that timing is such that the calculation condition fully runs prior to the macro trying to do things, that would be the only potential solution for the macro issue I believe.


To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.