Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rcandeo
Creator III
Creator III

How can I make this kind of filter?

I wanna put in my application a variable so my user can input a certain date. Then I need to filter all my data has the field sale_date < date_variable.

How can I make this filter after the input value?

1 Solution

Accepted Solutions
Anonymous
Not applicable

Can be done by macro, something like this:

sub macro
set f = ActiveDocument.Fields("sales_date")
set v = ActiveDocument.Variables("date_variable")
f.Select "<" + v.GetContent.string
end sub

(I didn't test it, the could be some erros).

Regards,
Michael

View solution in original post

10 Replies
Not applicable

Using set analysis like this:

sum( {<sale_date={"<$(date_variable)"}>} SaleAmount)

rcandeo
Creator III
Creator III
Author

But this is to be used inside an expression, isn't it?

I want all data that has sale_date > date_variable not be showed.

Not applicable

Add a calculated dimension to the report: if(sale_date<=date_variable,1) and select Suppress When Value is Null and Hide the column.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

If you want to enforse a selection (with the same effect as selecting the dates in a List Box), - currently you can only do it using a Macro. If you can wait till version 9, you'll be able to use Actions to do the same.

regards,

Oleg

Not applicable

Search the forums for "variables getcontent macro select" and you will see discussions with code samples.

Anonymous
Not applicable

Can be done by macro, something like this:

sub macro
set f = ActiveDocument.Fields("sales_date")
set v = ActiveDocument.Variables("date_variable")
f.Select "<" + v.GetContent.string
end sub

(I didn't test it, the could be some erros).

Regards,
Michael

Not applicable

Call me silly, but why not just use native QV associative technology. Create a table with a field which is a date field from Max(sale_date) to Min(sale_date), one value for each day (you can also create month() and quartername(), etc., to allow easy selection of months and quarters, etc.). Then join this new table to the sale_date field in the load script. Then the user can just select a date (or month, or quarter, etc)... and the whole QV will be filtered by this selection. I will post an example calendar load script to the share QV in a min.

Anonymous
Not applicable

Anthony,
It would be too easy... We here prefer to do things a hard way... Smile
Or sometimes have to deal with the inflexible client requirements Confused

Regards,
Michael

Not applicable

I have created a quick calendar example and put it in the shared area. Here's a link:

http://community.qlik.com/media/p/63238.aspx