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: 
andy
Partner - Creator III
Partner - Creator III

How make a selection in a Pivot table from a button depending on expression values

Hi foolks,

I have a pivot table which in one expression holds the change in %.

I want to select just those rows which has a positive change.

My idea is to write a macro and loop through the pivot table and check if that column has a positive number. If so get the value from the first dimension and store that in an array and use that to make a selection on that field.

My first little problem is to convert from the text 4,8% into the double 4,8.

I've tried several conversion functions but cannot find any one that works in the Qlikview environment.

Any suggestions?

function SelectTG1(criteria)
'first sort the table on TG1
' SortTG1Func()

set chart = ActiveDocument.GetSheetObject("CH03")

set table = ActiveDocument.GetSheetObject( "CH03" )
for RowIter = 1 to table.GetRowCount-1
set tg1Change= table.GetCell(RowIter,11)
set cell = table.GetCell(RowIter,0)
if(NOT cell.IsNull AND cell.Length) THEN
'remove editing characters and convert text to a number
set current_value=CDbl(replace(tg1Change.text,"%",""))
msgbox(tg1Change.Text)
msgbox(current_value)
END IF

next
end function


brgds

Andy

1 Reply
andy
Partner - Creator III
Partner - Creator III
Author

Hi again,

I've left the idea of looping through the table since it just has to simpler than that.

I've created a small example with a very small Pivot-table. What I try to accomplish is to select just the rows which has positive values in the right column "summed values".

I've included a very small macro with just one row:

ActiveDocument.GetField("ID").Select ActiveDocument.Evaluate("sum(VALUE)'>'&0")

but it doesn't work at all. Anyone know how to do this in Qlikview?