Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have a table which contains some numbers say 1 to 100. My requirement is to show a message or alert once i click on any of the rows in the table if it is a prime number. I am not familiar with macros to deal with this situation. Can anyone guide me to achieve this. Help is much more appreciated since i am struggling to writa single macro for last one week.
Thanks,
sujeet
See attached qvw
Hi,
I am not able to open this file since i dont have the licensed version of Qlikview. Please paste the scripts.
Thanks,
Sujeet
The field which has the number is named Num.
In Document Settings|Triggers, I created an OnSelect Action for the Num field to run a macro:
=if(Getselectedcount(Num) = 1,'IsPrime')
Here is the macro script:
sub IsPrime
set val=ActiveDocument.Fields("Num").GetSelectedValues
intNum = val.Item(0).Text
if intNum = 1 then exit sub
blnIsPrime = True
for i = 2 to intNum -1
If intNum mod i = 0 then blnIsPrime = False
next
if blnIsPrime then msgbox "Prime"
end sub
Hi,
Thanks for the reply.
I tried the following steps as described by you.
Created my table with following data.
PrimeTable:
LOAD * INLINE [
numbers,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
];
Added a "table box".
Created the macro.
I have added the trigger in the following way.
But once I click any of the values the macro window comes which shows the vb script.
I dont know if have missed something.
Thanks,
Sujeet
I can't read the complete expression you set in the trigger.
You haven't posted your macro code.
When the macro window appears, is a lone of code highlighted? If so, which line?
This is working now. Thanks for your help