Query the Google Analytics API until empty table occurs


I have a question regarding the Google Analytics Query node. I am trying to loop and get x-times 10.000 results until the Google Analytics Query node comes back with an empty table. But how would I do it? I tried using the empty table switch and also the table row to variable node to look for an empty variable but could not get it to work. 

Here is my workflow that is not working http://media3000.de/knime.png

Could anybody please help and suggest  or even provide a working flow? 

Many thanks and best regards, 



You can not wrap a if around a loop end. If constructs as well as loops have to be treated like brackets. If you are opening a bracket, you need to close if  before another one opens up.

What you need to do inside the loop is: Generate a flow variable containing the number of rows and use this flow variable to finnish the loop when it is 0.

(e.g. using the extract table dim node)

Cheers, Iris


Hello Iris, 

I could get it to work using Generic Loop Start and Variable Condition End node that is listening for Empty Rows from the Extrac Table Dim node.

Thanks a lot for your suggestion and explanation!  :)

Best, Andy

Hi Andy,

I am also looking for a solution. Would you be so kind to provide yours?

Thanks a lot

Hi mikeg, 


does this screenshot help you?

It is worth to mention that Google Analytics does sampling. The bigger the timeframe the less accurate are the numbers delivered by the API. So a month doesn't deliver accurate results - choose exporting daily results instead and merge them in the end. This is why i use the first chunk loop to deliver smaller timeframes. Whether sampling will be applied can be checked using the Query Explorer — Google Analytics Demos & Tools

Best, Andy

Hi Andy. New to knime and suffering from information overload.

I know this is a long shot (given the time difference in posts), but I arrived at this forum because I was looking for information on how to loop GA api calls and this is the first place that seemed to have relevant information that made sense. I was wondering if you would be able to share the actual workflow (obviously with sensitive information removed) for the image your shared to see some of the inner workings. I think I understand it in principle, but it would be really helpful to see the variable flow etc.

Thank you,

Hi Jarrod,

please find attached the workflow. It did work (with an older version of Knime) but I don’t know if it still does because I have no valid credentials.

Best regards, Andy

GA Loop Iterate Date & Startindex SHARE.knwf (23.1 KB)

1 Like

Thank you. Your workflow concept helped, and I managed to get something working.

1 Like