Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to limit length of variable?

Hi everyone!

I'm developing an analysis tool for one of our customers in QV.. one feature of this app is the possibility to log the selections made by the user. This is realized through a variable which is refreshed with every action: its content gets thereby expanded with a timestamp (now()) and the current selection status (GetCurrentSelections()) in a new row (chr(13)). The content of the variable is displayed in a text box on a separate sheet. Thus, the user can explore the data and afterwards reproduce its actions through the log. Although this is already working very well, I would like to limit the variable to something like 300 rows (=300 last actions) because of performance aspects. I already added the possibility to clear the log-variable through a button manually. However, since the user might forget to push this button every now and then, an automatic solution seems reasonable..

I'm wondering if there is a possibility to limit the length of a variable row-wise? Only hint I found so far was using "autocommenting expression" but neither I wasn't sure if this really addresses my issue nor wasn't I able to implement it. Do you have any ideas how to solve this task?

Thank you!

1 Solution

Accepted Solutions
MarcoWedel

Hi,

I'm glad it worked.

Regarding the line breaks, maybe you could use this expression instead:

=Now()&': '&GetCurrentSelections(' // ')&Chr(13)&Chr(10)&If(SubStringCount(vSelHist,Chr(13)&Chr(10))<=9,vSelHist,Left(vSelHist,Index(vSelHist,Chr(13)&Chr(10),9)+1))

hope this helps

regards

Marco

View solution in original post

6 Replies
MarcoWedel

Hi,

maybe one solution might be:

QlikCommunity_Thread_247629_Pic1.JPG

QlikCommunity_Thread_247629_Pic4.JPG

QlikCommunity_Thread_247629_Pic5.JPG

QlikCommunity_Thread_247629_Pic3.JPG

=Now()&': '&GetCurrentSelections(' // ')&Chr(13)&Left(vSelHist&Repeat(Chr(13),9),Index(vSelHist&Repeat(Chr(13),9),Chr(13),9))

(replace 9 with max rows-1)

hope this helps

regards

Marco

vinieme12
Champion III
Champion III

create a counter variable to increment on every selection

and add condition to add to selection list only if counter variable value <300

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
jonathandienst
Partner - Champion III
Partner - Champion III

I think you can simplify this to a set variable action with expression

=Now() & ': ' & GetCurrentSelections() & Chr(10) & Left(vSelHist, Index(vSelHist, Chr(10), -1))

Will always drop off the last row, so this assumes that log file is already has the correct number of lines. You could create a 200 blank line starting value in a text editor, and paste that into the variable overview or use Repeat(chr(10), 200) in a set in the load script.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thanks for this great solution! Only disadvantage in my case is that the excel-export of the log now always is 300 lines long with a lot of line breaks..but I guess I can live with that.

Not applicable
Author

Thanks for your help! I have no idea why, but for some reason it didn't work in my application.. The initial pasted amount of line breaks is kept under the actual log history and therefore the variable isn't limited. However, I solved it with Marco's approach-

MarcoWedel

Hi,

I'm glad it worked.

Regarding the line breaks, maybe you could use this expression instead:

=Now()&': '&GetCurrentSelections(' // ')&Chr(13)&Chr(10)&If(SubStringCount(vSelHist,Chr(13)&Chr(10))<=9,vSelHist,Left(vSelHist,Index(vSelHist,Chr(13)&Chr(10),9)+1))

hope this helps

regards

Marco