Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to select multiple conditions within a single field via macros

Hello 🙂

Now I have macro:

sub SelectA
ActiveDocument.ClearAll
call ActiveDocument.Fields("Field1").Select("A")
end sub

it works.

I need

SelectAandB

sub SelectA
ActiveDocument.ClearAll
call ActiveDocument.Fields("Field1").Select("A,B")
end sub

It does not work.

Please help me.

P.S. I found the same posts in archive but it not helps me.

1 Solution

Accepted Solutions
Not applicable
Author

I find how:

sub SelectAandB
set f = ActiveDocument.Fields("Field1")
set fv = f.GetNoValues
fv.Add
fv.Add
fv(0).Text = "A"
fv(0).IsNumeric = false
fv(1).Text = "B"
fv(1).IsNumeric = false

f.SelectValues fv

end sub

View solution in original post

3 Replies
Not applicable
Author

I find how:

sub SelectAandB
set f = ActiveDocument.Fields("Field1")
set fv = f.GetNoValues
fv.Add
fv.Add
fv(0).Text = "A"
fv(0).IsNumeric = false
fv(1).Text = "B"
fv(1).IsNumeric = false

f.SelectValues fv

end sub

Not applicable
Author

Hi Artur,

here are some more examples:

sub SelectDates

startdate = ActiveDocument.Variables("vStartDate").GetContent.String
enddate = ActiveDocument.Variables("vEndDate").GetContent.String
selectstring = ">=" & startdate & " <=" & enddate
ActiveDocument.Fields("SelektDatum").Select selectstring
'ActiveDocument.Fields("DateSelection").Select ">=34374 <=39499"
msgbox selectstring

end sub

Sub SelectYears
set y=ActiveDocument.GetField("Year")
y.Select ">=" & 2007 & "<=" & 2008
End Sub


'set y=ActiveDocument.GetField("Year")
'y.Select 2009

'or:
'y.Select ActiveDocument.Evaluate("year(today())")

'or:
'y.Select ">=" & 2007 & "<=" & 2008

Rainer

gilbertomedeiro
Contributor III
Contributor III

Hey guys,

That's very useful for me! That's I was looking for!

Thanks!