Wednesday, November 26, 2014

SET ANALYSIS in Qlikview Part3 (YTD , MTD , Rolling 12 months)

Using a function
So far, we have selected members that we knew in advance they will be or not in the set. But we can also
use functions that will return members according to a test, a rank ….
4.6.1 Numeric function
Syntax: <Dimension = {" $(=f(args)) "}
the $ sign is used to expand or interpret the function
you want to get the last year of the application, use the function max([{set}] FieldName)
<Year = {"$(=max({1} Year))"}>
Please note:
- The max function, like any aggregation function, take into account the current selection
- We have used an inner set. {1} inside the max function means the whole application. If we do not
use it, the max function will return the last year among those chosen by the user
- We use two equal signs, 1 before the curly braces, 1 between the quotes
If you are looking for the previous year of the last year of the selection, you may write one of the two
syntaxes that are equivalent:
- <Year = {"$(=max({$} Year)-1)"}>
- <Year = {"$(=max(Year)-1)"}> , {$} = current selection, it is the default
Most of the time, the set analysis become tedious, especially when writing YTD, Moving Total,
Comparisons vs Year ago. One way to simplify the syntax is to populate some fields directly into the model.
Herebelow, the field A-1 stores the key for the Yr Ago period, P-1 stores the key for the previous period,
YTD stores a flag (1 or 0) to indicate if the period should be taken to compute the YTD data:
If you want to get the periods of the Year Ago, you just need to use the appropriate field and the concat
function:
sum({<MONTH=, YEAR=, TIME_KEY = {$(=concat([A-1], ',')) } >} VALEUR)
YTD:
sum({<MONTH=, YTD = {1}, YEAR = >} VALEUR)
YTD from Year Ago:
sum({<MONTH=, YTD = {1}, YEAR = {$(=YEAR-1)} >} VALEUR)
MOVING TOTAL 12 periods:
sum({<MONTH=, YEAR=, TIME_KEY={">$(=Max(TIME_KEY)-12) <=$(=Max(TIME_KEY))"}>} VALEUR)
MOVING TOTAL 12 periods, Year Ago:
sum({<MONTH=, YEAR=, TIME_KEY={">$(=Max(TIME_KEY)-24) <=$(=Max(TIME_KEY)-12)"}>} VALEUR)


Function returning members
The text function is between quotes. No $ sign.
Syntax: <Dimension = {"=f(parameters) "} >
We want to aggregate the volume sales for the MANUFACTURERs whose value sales is greater than
100,000 dollars based on the current selection:
sum( {$ <MANUFACTURER_LDESC={"=sum([Value Sales])>100000"} >} [Volume Sales])
But we can also decide to search the MANUFACTURERs on a specific period, or for specific products. We
will create an inner set:
sum( {$ <MANUFACTURER_LDESC={"=sum({1<TIME_SDESC={'P 01/13'},
CATEGORY_LDESC={'ACC','CHEESE CAKE’ }>} [Volume Sales])>100000"} >} [Volume Sales])
Remember that the members could be enclosed between single or double quotes. Because the function
uses double quotes, we will use for the members either the single quotes or the square brackets [].
I want to find the Manufacturers whose sales are over 100,000 for the 2 categories CHEESE CAKE and
ACC in January 2013 (period P01/13). But I want to remove from that list those whose sales are lower than
50,000 for all categories in January 2012:
I need two sets : {<set 1> - <set 2>}, each of them will use the function sum():
Set 1 = 1 <MANUFACTURER_LDESC={"=sum({1< TIME_SDESC={'P
01/13'},CATEGORY_LDESC={'ACC','CHEESE CAKE'}>} [Value Sales])>50000"} >
Set 2 = <MANUFACTURER_LDESC={"=sum({1< TIME_SDESC={'P 01/12'},CATEGORY_LDESC={'*'}>}
[Value Sales])>100000"} >}
In a global syntax :
sum( {1 <MANUFACTURER_LDESC={"=sum({1< TIME_SDESC={'P
01/13'},CATEGORY_LDESC={'ACC','CHEESE CAKE'}>} [Value Sales])>50000"} >
- <MANUFACTURER_LDESC={"=sum({1< TIME_SDESC={'P 01/12'},CATEGORY_LDESC={'*'}>} [Value
Sales])<50000"} >}
[Value Sales])
this could be reduced a little :
sum( {1 <MANUFACTURER_LDESC={"=sum({1< TIME_SDESC={'P01/13'},CATEGORY_LDESC={'ACC',
'CHEESE CAKE'}>} [Value Sales])>50000"} -{"=sum({1< TIME_SDESC={'P01/12'},CATEGORY_LDESC={'*'}>} [Value Sales])<50000"} >}
[Value Sales])
Please note that the function is between quotes: you will have no help to write the syntax, for the function,
nor for the fields. QlikView is case sensitive for the field names: if you write TimeKey instead of TimeKEY,
you will get 0. So test the function before including it in the set analysis.
If you want to get the Top 20 products:
Sum({<Product = {"=rank(sum(Sales), 4)<= 20"}>} Sales)
And now the Top 20 products of the brand 10 (we need to use an inner set):
Sum({<Product = {"=rank(sum({<Brand = {10}>} Sales), 4)<= 20"}>} Sales)
Take care NOT to write:
Sum({<Brand = {10}, Product = {"=rank(sum(Sales), 4)<= 20"}>} Sales)
You would get the intersection of Brand 10 and the top 20 products. And perhaps, you will get nothing
because there is no product of the brand 10 among the top 20 products.
Keep also in mind that the set analysis is “computed” once, before the chart is computed. Not

once per row: you will not get different products by region if you have a region dimension in your chart.

SET Analysis in Qlikview Part2

Search string
Sometimes, we want to get all MANUFACTURERs with a specific name or which contain specific letters in
their name:
Syntax: {<Dimension = {"*search string*"}>}
· * = 0 to several characters (P1* will return P1, P10, P11 …)
· ? = 1 character (P1? will return P10, P11 … but not P1)
We can do several search strings in the same set:
Syntaxe : {<Dimension = {"*search1*", "fixed text", " ?earch2*"}>
Ex : {<MANUFACTURER_LDESC = {"ENT*", "?LIS*"}, CATEGORY_LDESC={"A?? "} >}
It is why we get all members (except NULL value because the NULL values do not have any character) of a
dimension with the star: <Dimension = {"*"}> or as explained earlier by placing nothing at the right of the equal sign <Dimension =>. The two following sets are identical if you do not have any NULL value in your field. If you have any NULL value in your field and want to select it also, choose <Dimension=>. In the
database used as example, there is no NULL dimension value:
Ex: ALL Manufacturers, only ONE category
{<MANUFACTURER_LDESC = {"*"}, CATEGORY_LDESC={"ACC"} >}
{<MANUFACTURER_LDESC =, CATEGORY_LDESC={"ACC"} >}
Ex: All MANUFACTURERs except those whose name begins with ENT
{<MANUFACTURER_LDESC = {"*"} - {"ENT*"}>}
{<MANUFACTURER_LDESC = - {"ENT*"}>}
Ex: All MANUFACTURERs of the selection + those whose name begins with ENT
{<MANUFACTURER_LDESC += {"ENT*"}>}
Ex: All MANUFACTURERs of the selection except those whose name begins with ENT
{<MANUFACTURER_LDESC -= {"ENT*"}>}

Take care: {<MANUFACTURER_LDESC -= {"ENT*"}>} and {<MANUFACTURER_LDESC = -
{"ENT*"}>} are very different. The first set removes from the current selection all MANUFACTURERs
whose name begins with ENT, while the second set selects all MANUFACTURERs except those who begin
ENT : the {"*"} is by default.
Ex: All MANUFACTURERs, Alls categories whatever the selections
{<MANUFACTURER_LDESC = {"*"}, CATEGORY_LDESC={"*"} >}
Ex: All years (because it is numeric, no quote), all categories
{<Year = {*}, CATEGORY_LDESC={"*"} >}
%Categorie: sum([Sales])/sum({$ <CATEGORY_LDESC={"*"}>} [Sales])
%Fabricant : sum([Sales])/sum(TOTAL [Sales])
Fabricant = Manufacturer. Fabricant is a dimension of the tableau. Category is not a
dimension: it has been set through a ListBox.
QlikView accepts the single or double quotes, the square brackets also for the search string:
Ex:
{<MANUFACTURER_LDESC = {"E*"}, CATEGORY_LDESC={"A??”} >}
{<MANUFACTURER_LDESC = {‘E*’}, CATEGORY_LDESC={‘A??’} >}
{<MANUFACTURER_LDESC = {[E*]}, CATEGORY_LDESC={[A??]} >}
4.4 Using a boundary for an integer dimension
Most of the time, Years are numeric. That is also the case for many keys because QlikView (as SQL) is faster when joining numeric keys than string keys.
The syntax is quite strange because you need to insert the code between double quotes:
{<TIME_KEY = {"<12”} >}: All the TIME_KEY members less than 12
{<TIME_KEY = {">=12 <=18”}>}: key members between 12 and 18, both included
Ex: keys 4, 5, 6 and those between 12 and 20 (20 is excluded)
{<TIME_KEY = {4, 5, 6} + {">=12 <20”}>}

Using a variable
4.5.1 Using a variable storing one or several members
Syntax: <Dimension = {$(NameVariable)} >
Or <Dimension = {$(=NameVariable)} >
(with or without the = sign in front of the variable)
Please note that $(=NameVariable) will interpret the variable and therefore QlikView rewrites the
command before executing it.
The content of the variable may contain several members, as if they were in the real syntax. Enclose them
between quotes or bracket according to their name.
Ex :
<MANUFACTURER_LDESC = {$(vChoiceMANUFACTURER)}, CATEGORY_LDESC={$(=ChoiceCategory)}>
There is another $ sign in the set analysis that means the current selection
$(NameVariable): it can be enclosed between double quotes or not like in the example above. If there is no quote, you may add some in the text of the variable because the member names contain spaces.
4.5.2 Using a variable storing a search string
A normal set: {<MANUFACTURER_LDESC = {"E*"}, CATEGORY_LDESC={"A??”} >}
The variable vChoiceProduit stores a search string and also the double quotes "E*":
{<MANUFACTURER_LDESC = {$(vChoixProduit)}, CATEGORY_LDESC={[A??]} >}

Using a variable storing integer members
With integer keys, you need to enclose the variable name between double quotes:
{<TIME_KEY = {"<$(vFirstPeriod)"}>}
Or {<TIME_KEY = {"<$(=vFirstPeriod)"}>}
The periods between two dates:
{<TIME_KEY = {">$(vFirstPeriod) <$(=vLastPeriod)"} >}
4.5.4 Using a variable storing a dimension
We have already seen that we can use variables with the $ sign. This variable may contain members but
also a dimension:
Ex: sum( {$ <$(vDim)={"*"} >} [Volume Sales])
Because the dimension may contain spaces or specific characters, it would be safer to use the square
brackets (remember that QV rewrites the syntax, so once your dimension name with a space replace the
variable, you would add brackets): sum( {$ <[$(vDim)]={"*"} >} [Volume Sales])
4.5.5 Using a variable storing the whole set
We can store members or dimension into a variable. Why not put the whole syntax?
Ex: sum({$ <$(vSet) >} [Volume Sales])
Ex: sum({$ <$(vSet), CATEGORY_LDESC= "ACC" >} [Ventes Volume])
As you see, we can store the complete syntax or just part of it!
The vSet variable must contain a valid syntax except <> like :
- MANUFACTURER_LDESC ={"*"}, TIME_SDESC={"P 01/13"}
- Year={$(=max({1} Year))}, TIME_LDESC=
- …

Set Analysis in Qlikview Part1

Why use the sets

The sets let you create a different selection than the active one being used into the chart or table. The
created group let you compare the aggregations of this group and the one of the current selection.
These different aggregations let you compare for example the sales of the current month and those of the
previous year, create YTD or moving totals. You may also create market shares, a percentage of the
products, of the year ….
A set modifies the context only during the expression that uses it. Another expression without any
set will get the default context, standard selection or the group of the Alternate State.
A set is always written between curly braces {…}. A set can modify the selection of one or several
dimensions. It can be composed of a single set but can include also an inner set.
A set may be composed of:
- An identifier
- An operator
- A modifier
These 3 fields are optional. Of course, to write a set, you will need to incorporate one or several of thesefields.

Limitation:take care, a set analysis is calculated once per chart (or table). NOT once per row. If you
want a different result in your set analysis according to the row being calculated and displayed, it will NOTwork. Change the way to compute your data (model, if statement) but forget the set analysis.

The identifier

0 – empty set
1 – complete application
$ - current selection (take care that sometimes your chart or table does not use the current selection but an
Alternate States)
$1 – previous selection ($2: the second previous selection, etc.)
$_1 – next selection
Bookmark01 – name or ID of a bookmark
Group – group name (Alternate State)
Sum({Book1} [Sales]) : sales of the selection of Book1
Sum({Group1} [Sales]) : sales of the Alternate State Group1 (the syntax is identical)
Sum({1} [Sales]) : sum of everything (All dimensions are completly reset to All)
Sum({$} [Sales]) : sum of the current selection (= sum([Sales])

 The operators

+ : union of sets
*: intersection of sets
- : Exclusion of two sets
/ : members belonging to only one of the two sets
If you use the operators with the equal sign:
<Dimension += another set>: add the set to the current selection
<Dimension -= another set>: remove the set from the current selection
Sum({1-$} [Sales]) : sum of the sales of the « database » except the current selection
Sum({GROUP1 * Book1} [Sales]) : sum if the sales for the intersection of Group1 and Book1 (the
members belonging to both)

Sum({1-$} [Sales]) : sum of the sales of the « database » except the current selection
Sum({GROUP1 * Book1} [Sales]) : sum if the sales for the intersection of Group1 and Book1 (the
members belonging to both)

The sets that we will study are between angle brackets : <>. They are quite more complex also. But you may use also the operators:

{<set 1> -<set 2>} or {set 1}-{set 2}: members in the set1 that are not in the set2 (because we remove them)

The modifiers

Yes, that is the tricky part of the Sets Analysis ! With them, you can reduce or enlarge the scope of the
selection used in an aggregation. You may modify the selection for one or several dimensions.
A set analysis is not like clicking in the ListBoxes. If you decide to set a dimension to a specific value
currently not selected:
- In the ListBoxes, you will get a new selection
- In the set analysis, you will NOT: you will just set this dimension to this member (and the
intersection with the current selection may be empty)
A set analysis is calculated before the chart is computed and redrawn. As you may notice, it is NOT
calculated per each row/column in the chart. So, you may not guess a scope of product depending on the rows that are products. You may not guess another set of periods depending of the columns if the Period dimension is in column : the YTD or moving totals you may encounter are often valid only if the period is not a dimension of the chart.

All members

{Starting selection <Dimension1 = {*} >} ({*} for numeric, {"*"} for text)
Or:
{Starting selection <Dimension1 = >}
The starting selection may be the current one ($ by default) or the complete application 1 or the name of a group or a bookmark .
If you want all members of one dimension, you can write at the right of the equal sign:
- {*} or {"*"} if the dimension is text: selects all members except the NULL
- nothing  As you can see below, the {*} can be omitted.
Ex: All MANUFACTURERs but one CATEGORY
{<MANUFACTURER_LDESC = {"*"}, CATEGORY_LDESC={"ACC"} >}
{<MANUFACTURER_LDESC =, CATEGORY_LDESC={"ACC"} >}

Take care if you have created several ListBoxes on the same logical dimension, like TIME. If you
have a Listbox for Month and one for Year, please keep in mind that the user can select on both fields, and
therefore limit the scope of Time by these two fields.
Check the difference between these 2 sets:
{<YEAR = {2012}>} will get the year 2012 but only for the months that have been selected in the ListBox
(that is not the Total of the Year 2012)
{<MONTH=, YEAR = {2012}>} will get ALL months of the year 2012
Each time you have a hierarchical dimension and display several Listboxes, take care to reset to all every dimension except the one you want to select. By setting a value of one dimension, you do not select any associated members (as QlikView does naturally with the ListBoxes).

Known members
Syntax :
{Selection <Dimension1 = {member 1, member 2, …} [, Dimension2 = {member 1,
member 2, …}] >}
Ex : {<MANUFACTURER_LDESC = {AMBOISE, BELLE, AUTREMENT}>}
Ex : {<MANUFACTURER_LDESC = {AMBOISE, BELLE, AUTREMENT}, CATEGORY_LDESC={ACC}>}
In the global syntax: sum({<MANUFACTURER_LDESC = {AMBOISE, BELLE, AUTREMENT}>} [Value Sales])
Please note that:
- The selection may be the current one ($ sign), the database (1), a bookmark or a group. The current
selection is the default selection, the $ may be omitted.
- There is no comma (,) between the set and the measure name
- The dimension or the measure name must be enclosed into brackets [] if the name contains specific
characters like a space, a hyphen (-) …
- Members are always enclosed into curly brackets {} : whatever the way to find them (by name, by
search string, by a function)
- Named members are separated with a comma (,)
- Numeric member names are not enclosed into single or double quotes
- Text members are enclosed into single or double quotes but not necessarily if they do not contain
specific characters like spaces
Ex: {<MANUFACTURER_LDESC = {"AMBOISE","BELLE"}, CATEGORY_LDESC={"ACC", "COLD PLATES
”}>}
Ex: {<MANUFACTURER_KEY = {253, 2789, 1200}, CATEGORY_LDESC={"ACC", "COLD PLATES”}>}
If we do not write anything between the curly brackets, the set is empty:
Ex: {<MANUFACTURER_LDESC = {}, CATEGORY_LDESC={ACC} >}
If we compute some flags (1 or 0 according to a test) into the script, we may use them easily in the set
analysis:
Sum({<Flag = {1}, Year={2014}, Month= >} Sales)


Using Exists and Keep to limit the data load in Qlikview Script

Using Exists and Keep to limit the data load
Quite often, we need to restrict the amount of data that we are loading. We can usually do this
by comparing the value in a particular field to some other value (for example, Year > 2010),
but we might also need to load the data based on the values that have already been loaded
into memory.

Load the following script:
Sales:
LOAD * INLINE [
Year, Country, SalesPersonID, Sales
2011, Germany, 1, 1233
2012, Germany, 1, 2133
2013, Germany, 1, 3421
2011, UK, 2, 1567
2012, UK, 2, 2244
2013, UK, 2, 2567
2011, USA, 3, 1098
2012, USA, 3, 1123
2013, USA, 3, 1456
];

SalesPerson:
LOAD SPID As SalesPersonID,
SalesPersonName as SalesPerson;
Load * INLINE [
SPID, SalesPersonName
1, John Smith
2, Jayne Volta
3, Graham Brown
4, Anita Weisz
];
Budget:
LOAD * INLINE [
Year, Country, Budget
2012, Germany, 2100
2013, Germany, 3100
2014, Germany, 4100
2012, UK, 2100
2013, UK, 2600
2014, UK, 3100
2012, USA, 1100
2013, USA, 1200
2014, USA, 1300
];

These steps show you how to use Exists and Keep to limit the data load:
1. Add a listbox for Year and one for SalesPerson. Note that there are four values in
each. However, there is one extra sales person that we don't need at this time. There
is also a year's budget that we don't need to include. Modify the SalesPerson table
load as follows:
SalesPerson:
LOAD SPID As SalesPersonID,
SalesPersonName as SalesPerson
Where Exists(SalesPersonID, SPID);
Load * INLINE [
SPID, SalesPersonName
1, John Smith
2, Jayne Volta
3, Graham Brown
4, Anita Weisz
];
2. Modify the Budget load as follows:
Budget:
Left Keep (Sales)
LOAD * INLINE [
Year, Country, Budget
2012, Germany, 2100
2013, Germany, 3100
2014, Germany, 4100
2012, UK, 2100
2013, UK, 2600
2014, UK, 3100
2012, USA, 1100
2013, USA, 1200
2014, USA, 1300
];
3. Reload the script and note that each listbox only has three values. Open the table
viewer and note that the budget is still a separate table.
4. Modify the Keep statement for the Budget load to the following:
Inner Keep (Sales)
5. Reload and note that there are now only two values in the Year listbox.
How it works...
The Exists clause on the SalesPerson load checks to see if the value being loaded (SPID)
already exists in the already loaded data (SalesPersonID). If it does, then the sales person
gets loaded.
The Keep clause acts in a similar way to a Join statement, except that the tables are not
joined. Rows in the tables are only kept if they match the join. In the first case, we use a Left
Keep so the data in the Sales table is all retained and we just don't load the budget data
that doesn't match. In the second case, (the Inner Keep), both tables lose the records that
don't match an Inner.


 <!-- Begin BidVertiser code -->
<SCRIPT LANGUAGE="JavaScript1.1" SRC="http://bdv.bidvertiser.com/BidVertiser.dbm?pid=637728&bid=1590320" type="text/javascript"></SCRIPT>
<noscript><a href="http://www.bidvertiser.com/bdv/BidVertiser/bdv_publisher_toolbar_creator.dbm">toolbar creator</a></noscript>
<!-- End BidVertiser code --> 

Qlikview Interview Questions and Answers Part2

//Q1. list of labels where artist name is 'Kylie' using left joins(using
TextBetween string function)
Q1_2:
LOAD lngLabelID,strLabelName,strArtistName
resident Master
where strArtistName=TextBetween('<Kylie Minogue>', '<', '>');

drop table Q1_2;

//Q1. list of labels where artist name is 'Kylie' using left joins(using
input box)
Q1_3:
LOAD lngLabelID,strLabelName,strArtistName
resident Master
where strArtistName='$(art_name)'; //art_name is the inputbox variable
drop table Q1_3;

//Q1. list of labels where artist name is 'Kylie' using left joins(using
Left string function)
Q1_4:
LOAD lngLabelID,strLabelName,strArtistName
resident Master
where left(strArtistName,5)='Kylie';

drop  table Master;


//Q1.where artist name should have 'MI' in it

LOAD      lngAlbumID,strAlbumName,strArtistName
resident Master
where strArtistName like '*Mi*' ;

//Q2.where album name has digits in it

LOAD  strAlbumName
resident Master
where keepchar(strAlbumName,'0123456789');

//Q3.where album name has '.' in it

LOAD   strAlbumName
resident Master
where strAlbumName like '*.*' ;


//Q4.where album name has only one '.' in it

LOAD   strAlbumName
resident Master
where subfield(strAlbumName,'.');

drop table Master;


//Q5.where album name has only more than 2 occurences '.' in it

LOAD   strAlbumName
resident Master
where substringcount(strAlbumName,'.')>2;//this enables us to limit the no
of charachters

drop table Master;


//Q6.album names without 'the'

LOAD   strAlbumName
resident Master
where substringcount(lower(strAlbumName),'the')<1;

drop table Master;



//Q1:Make three fields from email field username,domain_name,domain_extension
Contacts:
LOAD Address,
     City,
     Country,
     Email,
     FirstName,
     LastName,
     Message,
     Phone
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\25_feb_2011\Contacts.qvd]
(qvd);

resi_1:
load Email,
TextBetween(Email,'','@') as Username,
TextBetween(Email,'@','.') as Domain_name,
TextBetween(lower(Email),'.','')  as Domain_extension
resident Contacts;

drop table Contacts;

//domain extension wise count of domain name
load Domain_extension,count(Domain_name)
resident resi_1
group by Domain_extension;

//domain name wise count of username
load Domain_name,count(Username)
resident resi_1
group by Domain_name;

//Q2.name of customers having 'a'and 'c' and 'u' in their names


//solution1:
load Customer
resident Master
where Customer like '*a*' and Customer like '*c*' and Customer like '*u*';

drop table Master;

//solution_2:
load Customer
resident Master
where (substringcount(lower(Customer),'a')>=1)
and   (substringcount(lower(Customer),'c')>=1)
and   (substringcount(lower(Customer),'u')>=1);

drop table Master;

//Q3.replace '&' by 'and' , 'Supermarket' by 'Store','Store' by
'Shop','Shop' by 'Market'

Resi_1:
load Customer ,
     replace(Customer,'&',' and ') as Cust1,
     replace(Customer,'Supermarket','Store') as Cust2,
     replace(Customer,'Store','Shop') as Cust3,
     replace(Customer,'Shop','Market') as Cust4
resident Master;

drop table Master;



 <!-- Begin BidVertiser code -->
<SCRIPT LANGUAGE="JavaScript1.1" SRC="http://bdv.bidvertiser.com/BidVertiser.dbm?pid=637728&bid=1590320" type="text/javascript"></SCRIPT>
<noscript><a href="http://www.bidvertiser.com/bdv/BidVertiser/bdv_publisher_toolbar_creator.dbm">toolbar creator</a></noscript>

<!-- End BidVertiser code --> 

Qlikview Interview Questions and Answers Part1

Q1.query which displays month which has the highest no of orders

since straight table supports row limitation v can take count first(as nested agg func is not supported) and then select the max and limit the rows to 1)

LOAD
count(distinct OrderID) as ord_count, month(OrderDate) as mth
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\Orders.qvd]
(qvd)
group by month(OrderDate);

Q2. list all employees born in month of june (give name& count)there r no bdys hence no output shows bt it wrks for otr months

resi_1:
LOAD
     EmployeeID as June_bdy
resident employee_dm
where month(BirthDate)='jun';

Q3.display the list of employee where suppid same as emplid

suppid_emplid:
LOAD
     OrderID,EmployeeID
     FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\Orders.qvd]
(qvd);

inner join

LOAD distinct OrderID,
     ProductID
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\Order_details.qvd]
(qvd);

inner join

LOAD
     ProductID,
     SupplierID
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\Products.qvd]
(qvd);

inner join

LOAD   SupplierID
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\Suppliers.qvd]
(qvd);

resi3:
load SupplierID as supp_id
resident suppid_emplid
where SupplierID=EmployeeID;


Q4.display supplier's name wher units in stock is '0'
to reduce time,code,load we can use where clause in the load itslf

ZeroStock:
LOAD      ProductID,
     SupplierID,
     UnitsInStock

FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\Products.qvd]
(qvd)
where UnitsInStock=0;

inner join

LOAD CompanyName,
     SupplierID
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\Suppliers.qvd]
(qvd);

Q5.create a bucket(range of counts of products) and the count of
suppliers falling in those category

count_prods:
LOAD SupplierID,count(ProductID),
if(count(ProductID)<=2,'0-2',
        if(count(ProductID)<=6,'3-6',
                if(count(ProductID)<=9,'7-9',
                        if(count(ProductID)<=12,'10-12')

                    )
            )
    ) as buck
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\Products.qvd]
(qvd)
group by SupplierID;

resi_count_prods:
LOAD count(SupplierID),buck
resident count_prods
group by buck;

drop table count_prods;

//to show blank buckets we concate data with a blank bucket table to
//force buckets to be seen using inline

concatenate
LOAD * INLINE [
    buck,supp_cnt
    7-9
    10-12
];

drop table count_prods;


// list of labels where artist name is 'Kylie' using left joins

Master:
LOAD dteAlbumReleaseDate,
     lngAlbumID,
     lngGenreID,
     lngLabelID,
     strAlbumName
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\25_feb_2011\Album.qvd]
(qvd);

left join

LOAD lngLabelID,
     strLabelName
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\25_feb_2011\Label.qvd]
(qvd);

inner join

LOAD lngAlbumID,
     lngArtistID
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\25_feb_2011\link.qvd]
(qvd);

inner join

LOAD lngArtistID,
     strArtistName
FROM
[C:\Documents and Settings\11050.TCPL\Desktop\Almas\25_feb_2011\Artist.qvd]
(qvd);




WHAT IF! ANALYSIS USING SET ANALYSIS in Qlikview


The below expressions were used in the chart against the dimension of
'Products' to show the difference between year 1997 and 1996 using a
slider object(scrollbar) with a variable
'Quantity' 'vQty' and for 'Unit Price' 'vPrice'


sum({$<Year={"1997"}>}Quantity)

= >gives the values of 'Quantity' field for the year of 1996

sum({$<Year={"1997"}>}Quantity) *vQty

= >gives the values of 'Quantity'  field multiplied by the value selected in
the scrollbar where 'vQty' is the variable used for the scrollbar

(sum({$<Year={"1997"}>}Quantity) *vQty)+(sum({$<Year={"1996"}>}Quantity))

gives the value + increased value ie the value after the increment/decrement

=((sum({$<Year={"1997"}>}Quantity)
*vQty)+(sum({$<Year={"1997"}>}Quantity)))-(sum({$<Year={"1996"}>}Quantity))



gives the value of 1997 Quantity  -  the value of 1997 Quantity after the
increment/decrement made in the scrollbar to show the difference in the
Quantity sales of the year 1997

similarly

=((sum({$<Year={"1997"}>}Quantity)
*vQty)+(sum({$<Year={"1997"}>}Quantity)))*((sum({$<Year={"1997"}>}UnitPrice)
*vPrice)+(sum({$<Year={"1997"}>}UnitPrice)))-((sum({$<Year={"1996"}>}Quantity))
* (sum({$<Year={"1996"}>}UnitPrice)))


gives the effect on both Quantity and Unit price which gives us the sales
value comparison on increasin year 1997's value
(sales =Quantity*Unit price)