Friday, June 12, 2015

Set Analysis-I

Expression
Meaning
sum({­<Ye­ar=­{“<2015”}>} revenue)
Less than 2015 year
sum({­<Ye­ar=­{“>=2011 <=2015”}>} revenue)
Less than 2015 year, Greater Than 2011 (inclusive)
sum({­<Ye­ar=­{2005, 2007} + {“>=2011 <2015”}>} revenue)
2005, 2006, Less than 2015 year (Excluding 2015), Greater Than 2011 (including 2011)
sum( {$ <$(vDim)={"*"} >} [revenue])
We can use variables with the $ sign. This variable may contain members but also a dimension
sum({$ <$(vSet) >} [Volume Sales])
Using a variable storing the whole set
vSet variable must contain a valid syntax except <> like MANUFACTURER_LDESC ={"*"}, TIME_SDESC={"P 01/13"}
Ye­ar=­{2005, 2007} + {“>=2011 <2015”}
<Year = {"$(=max({1} Year))"}>
Using a function
<Dimension = {" $(=f(args)) "}>
Sum({<KeyAutoNumber = {"=(DayDelivery=DayOrder)" } >} Sales)

Sum({<KeyAutoNumber = {"=(DayDelivery < DayOrder -7)" } >} Sales)
Using two fields
We want to get the sales that have been delivered the same day. We have two fields : DayDelivery and
DayOrder
Sum(if(DayDelivery=DayOrder, Sales))
You can get an equivalent to the above syntax but this is slower because QlikView needs to compute all
the lines of the scope:
sum({<$(vSet)>} Sales)
Let’s create a variable vSet that will be a formula:=if(GetSelectedCount(Product)=1, 'Product=', '$')

Set Analysis-II

Expression
Meaning
sum({$­<Ye­ar=­{2000}, Country = {"U*­"­}>} revenue)
Current selection but year forced to 2000 and region like U*
sum({$­<Year = {$(vLa­stY­ear­)}>} revenue)
sum({$­<Year = {$(=vLa­stY­ear­)}>} revenue)
Revenue related to a variable (With or without = sign in front of variable
p({<Ye­ar=­{$(­=ma­x(Y­ear­)-1­)}>} customer)
Returns customers who are possible for last year
e({<Ye­ar=­{$(­=ma­x(Y­ear­)-1­)}>} customer)
Returns customers who are excluded for last year
Sum({1-$} [Sales])
sum of the sales of the « database » except the current selection
Sum({<Flag = {1}, Year={2014}, Month= >} revenue)

Sum ({<customer _name = {“x”, “a”, ”p”}>} revenue)
Sum ({<customer _name = {‘x’, ‘a’, ‘p’}>} revenue)
Sum ({<customer _name = {[x], [a], [p]}>} revenue)
Sum ({<customer _name = {x, a, p}>} revenue)

Sum ({<customer _name = {“x*”, “a?”, “?p*”}>} revenue)
* = 0 to several characters (x* will return x1, x01, x21 …)
? = 1 character (a? will return a1, a1 … but not a11)
Sum ({<customer _name = {“*”} - { “a*”}>} revenue)
Sum ({<customer _name =  - { “a*”}>} revenue)
All customers except those whose name begins with a
Sum ({< customer _name += {"abc*"}>})
All customers  of the  current selection + those whose name begins with abc
Sum ({< customer _name -= {"abc*"}>})
All customers  of the current selection - those whose name begins with abc

Set Analysis-III

Expression
Meaning
sum(revenue) 
sum({$} revenue)
Revenue in current selection. sum of the current selection (= sum([revenue])
sum({1} revenue})
sum({1} Total revenue})
Revenue disreg­arding the selection or disreg­arding selection and dimension. sum of everything (All dimensions are completely reset to All)
sum({$­<revenueDate = “12 Jan 2015”>} revenue)
Revenue in current selection for a specific date
sum({1­<Country = {US}>} revenue)
sum({1­<Country = {“US”}>} revenue)
sum({1­<Country = {‘US’}>} revenue)
sum({1­<Country = {[US]}>} revenue)
total revenue for country=US
sum({<Country = >} revenue)
Revenue in selection with country removed (idem $)
sum({<Country = {“*”}>} revenue)
sum({<Year = {*}>} revenue)
Revenue in selection with country removed (idem $)
({*} for numeric, {"*"} for text
For All Country