Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Skip the ticket, Chat with Qlik Support instead for instant assistance.
cancel
Showing results for 
Search instead for 
Did you mean: 
cliff_clayman
Creator II
Creator II

Best Practice for filtering reports by variable

I have a variable for Current Year and Previous Year.  I am creating some reports that have a lot of expressions in them that are dependent upon one or both of these variables.  I am trying to figure out what is the best way to filter a report by just Current Year.  Should I used a calculated dimension?  Should I put the variable in each expression?  I want to be consistent and utilize the best practice.  Can someone please explain what is the best practice here?

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Not really. If you have a variable that defines "Current Year" in a numerical format (i.e. not as an expression) then you better use something like:

=Sum({$<Year = {$(vCurrentYear)}>} Sales)

This technique will perform a $-sign substitution before evaluating the expression. It allows you to change the value of the Current Year without changing any expression.

View solution in original post

5 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Can you post an example of your documents? It is rather difficult to post a best practice for something that is highly context-dependent. Thanks.

cliff_clayman
Creator II
Creator II
Author

I don't think a specific example will make much of a difference.  I'm just looking at it from an overall perspective.

  

StoreSalesRevenue
1$1,000,000.00$500,000.00
2$2,000,000.00$1,000,000.00
3$3,000,000.00$1,500,000.00
4$4,000,000.00$2,000,000.00
5$5,000,000.00$2,500,000.00

Take something as simple as this.  This data includes values from all years.  I want to be able to limit it to only the Current Year.  Is it best to use a calculated dimension, define the variable in each expression, or some other way?

Peter_Cammaert
Partner - Champion III
Partner - Champion III

IMHO the easiest way to limit a chart to diplay just data for the current year is to use set analysis. But then again, I have no clue what the circumstances are.

cliff_clayman
Creator II
Creator II
Author

So, using Set Analysis, I would always need to define the value for that field.  Something like this...

Sum({$<Year={2016}>}Sales)

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Not really. If you have a variable that defines "Current Year" in a numerical format (i.e. not as an expression) then you better use something like:

=Sum({$<Year = {$(vCurrentYear)}>} Sales)

This technique will perform a $-sign substitution before evaluating the expression. It allows you to change the value of the Current Year without changing any expression.