Q1 what are the roles and responsibilities of a QlikView developer?
it involves creation of dashboards which contains data model (Snowflake or Star schema) as per requirement and wherein Data is extracted from various Sources sstems like Sql Server!"racle!#xcel file and data extracted from Source sstems are stored in a QVD form for faster retrieval of records and finall havin$ $raphical representation of Data in the form of %harts!&able 'ox etc for better nalsis or forecast to #nd user prospective and providin$ the section access to ensure that valid users are accessin$viewin$ the dashboard* "r #&+ dashboard desi$n ,& of dashboards with business users Support
Q- .hat is the role of end to end implementations in the QlikView pro/ect?
"k* 0 assume Qlikview is alread implemented in the or$aniation* &hen the next steps are2 3equirement $atherin$ Determinin$ data sources %reatin$ requisite connection strin$ to the database 4etchin$ the data in qlikview server and storin$ in QVD %reatin$ the data model %reatin$ the front end 0mplementin$ section access as required %reatin$ /obsassi$nin$ and schedulin$ for dail data load the dashboard %reatin$ id! the license and authoriin$ Support to the user #nhancements%han$es as required
Q3What Is a QVD file? QVD is a QlikView format and can onl be written to and read b QlikView* sin$le QVD file can store a sin$le table and is created in the load script in a QV. file* QVD file consists of three parts2
•
56+ header to describe the fields in the table! the laout of the subsequent information and other meta7data*
•
Smbol tables in a bte stuffed format*
•
ctual table data in a bit7stuffed format.
Q4 what are KPIS & its need in Dashboard?
Sup po sef orRet ai lmar ket , you ha ve ue qsi on ts i ke, l How muc h S al esha pp en d ast l yea r . . andWhati s cu r r ent st at e of Sal es,ar e we m eet i ng h t e Ta r get s( whi chmeans co untof sa l es) , Whi chSt or ei s pe r f or mi ngwel las co mpa r ed t o ot he r s. So t hesequest i ons a nd t he i r answ er s w i l l beco me yo ur KPI ' s o f rt he appl i ca t i on.
Pl easel etus kn ow ,f or whi chDomai n( Fi nan ce , Ret ai l et c)yo ur ap pl i ca t i on s io f r an d h t en c ommon KPI ' s can beshar edf r om f el l owmem be r s.
Or Key Performance Indicators are quantifiable measurements, agreed to beforehand, that reflect the critical success factors of an organization. They will differ depending on the organization. •
A business may have as one of its Key Performance Indicators the percentage of its income that comes from return customers.
•
A school may focus its Key Performance Indicators on graduation rates of its students.
•
•
A Customer Service Department may have as one of its Key Performance Indicators, in line with overall company KPIs, percentage of customer calls answered in the rst minute. A Key Performance Indicator for a social service organi!ation might be number of clients assisted during the year. Whatever Key Performance Indicators are selected, they must reflect the organizations goals, they must be !ey to its success,and they must be quantifiable "measurable#. Key Performance Indicators usually are long$term considerations. The definition of what they are and how they are measured do not change often. The goals for a particular Key Performance Indicator may change as the organizations goals change, or as it gets closer to achieving a goal.
Q5 what is your current ro!ect "rchitecture? not Qli#$iew architecture? Gener al l y Q l i kvi ew ap ps a r e de ve l op ed usi ng 3 ar ch i t ect ur es,
1 Ti er or l aye r 2 Ti er or l aye r 3 Ti er or l aye r
I n 1 Ti er , al lt he Dat a Ext r act i on sc r i pt s,Tran sf or mat i ons a nd Pr ese nt at i on ( ch ar t s)ar e done wi t h i n sa me q l i kvi ew fil e. I n 2 Ti er , al lt he Dat a Ext r act i on i s d one and st or ed i n QVD fil es n i one Ql i kvi ew fil e and Tr an sor fmat i onan d Pr esen t at i on us i ng QVD fil esge ne r at edi n pr evi ou s fil e ar e do newi t hi n ano t he r Ql i kv i ew fil e. I n 3 Ti er , Dat a Ext r act i on i s d one and st or ed i n QVD fil es n i on Ql i kvi ew fil e,Tr ansf or mat i on i s d one usi ng Ql i kvi ew fil es n i anot her fil e, Pr ese nt at i on i s d one i n anot her fil e usi ng Bi nar y o l ad of Tr ansf or med Q l i kvi ew fil e.
Q% what is difference between $d and $w?
QVW: A qlikview file saved in binary format having the default expression QVW. Also alled QlikView file.qvw file ontains tables! harts sript et. QV": a native Qlik View file format! A QV" file ontains one data table! no layout and no seurity. #t is basially a binary $%V file optimi&ed for fast loading. %r
1 QVD i s co l l ect i onofda t af r om t heda t ab ase , whe r ea s Q VW i s he t Ql i kvi ew ap pl i cat i on . Butbo t h QVD and VQ W ar e he t e fil or fmat s 2 QVD i s D at a w ar eh ouse an d t icover s dat a pa r t wher eas VQ W i s D esi gn pp Al i cat i on nd a ti cover s Dat a Pr es en t at i on .
Data "odeling in #li$%iew is a very broad concept. #li$%iew is a wonderful tool and it gives you whole gamut of functionalities to perfect your data model. &ith this blog my intention is to give #li$%iew beginners an insight into QlikView data modeling. I have received lot of emails from 'I developers who say that they are interested in #li$%iew but don(t $now from where to start. Some say that lot of information is available which they can search but atleast they should $now what they searching on. &ith this blog my ob)ective is that without going into too much details, give these developers an idea into #li$%iew data model,some important $eywords,functionalities and to drive them in e*ploring the awesome world of #li$%iew.
1. Load statement in QlikView In developing your application, rst thing you have to do is to load data. #li$%iew can e*tract data from disparate data sources such as +e*t les,-S,CS%,"-,#%Ds,SAP,relational db,cloud and custom datasources. +o load data from +e*t les,CS% les and #%Ds go to script editorCntl /01 and clic$ on +able les under Data from les. 2ou can load data from databases by clic$ing on connect and Select. 2ou can also copy your S#- 3uery directly into #li$%iew script editor. +here are many di4erent types of -oad statements in #li$%iew. Search on Load
statements in QlikView Loading excel fle in QlikView In #li$%iew you can connect to variety of data sources. #li$%iew can connect to 5D'C, 5-0D', "- data sources. 2ou can also connect to cloud data sources li$e Sales6orce.com.
In this e*ercise i want to show you how to connect to an excel fle in QlikView.
Steps: •
Create new #li$view document or use e*isting document
•
clic$ on edit script on the tool bar menu
•
Inside the script editor choose option for +able les
7se +able les to load e*cel les.7se Database drop down to select 5D'C and 5-0 D' connections. •
'rowse to your le and open
•
7se le wi!ard if you want to ma$e any changes to your le
0*cel le. 7se 8-abels9 drop down to include 80mbedded -abels9 to get the header information. 7se 8+ables9 drop down to load the specic tab in the e*cel le. •
:ive table name to your load script. #li$view will use this table name to identify your table
•
-oad data
•
%erify by creating a sheet ob)ect
;ight clic$ and select
Select 5rderId eld for your list bo*
5rder ID list bo*. Data in -ist bo* shows that data is loaded successfully.
What is Preceding load It allows you to dene multiple transformations and calculations within one load script which would otherwise will need to be created using separate load and resident load statements. It ta$es input from the previous Select statement. Preceding -oad is invo$ed by chec$ing the 8preceding load 9 while selecting the tables.
Another Advantage o Preceding Load is that it allows you to use QlikView unctions in the Load script -et us see how your script will loo$ when you don(t chec$ the 8preceding -oad9 while selecting the table.
Preceding -oad not chec$ed
-oad Statement without Preceding -oad -oading table without preceding load will not allow you to use #li$%iew functions.
-oad statement after chec$ing 8preceding load9 chec$ bo* In this script you can see that preceding load ta$es the input from the previous Select Statement. 2ou can select all the columns in the Select statement but in -oad statement you can select the ones you need. Also observe 2ear and "onth Calculations. Preceding -oad allows you to use #li$%iew functions li$e 2ear,"onth,Apply"ap etc. +here can be multiple preceding loads stac$ed one on the top of other.
Preceding load can be a useful tool to simplify your data transformations.
2. QVDs in QlikView #li$%iew data les compress data from the database. It is >?@>?? times faster to read data from #%Ds as compared to database. #%Ds are best for large datasets and to reduce load on the database. 2ou can e*tract data from db and store it in a #%D #%D can only be written or read from #li$%iew. 2ou can connect to the data source and e*port data in the table in a #%D. Advantage of QVD 5nce data is e*ported in the #%D you don(t have to connect to database. 2our data will reside in #%D. ;eading from #%D is >?@>?? times faster than reading from Data sources. Consolidating data from multiple data sources and databases. Create multi@layer #%Ds to create a robust data model. Incremental load can be implemented only by using #%Ds Storing Data in QVD
+able data can be stored in #%D by using BStore( Binto( commands
#%D le will be stored in the specied location.
Reading from a QVD
2ou can read data from a #%D )ust li$e reading from a table.
#%Ds can have calculations and e*pressions. 2ou can create and read from multiple #%Ds and they will be associated similar to tables. 5nce data is loaded in the #%Ds you don(t have to stay connected to data source thus reducing load on the database servers. 5nly time you will connect to database is when you need to refresh your #%D data with the updated data in the database. 2ou can schedule tas$ on the #li$%iew server to reload your #%Ds. +o schedule tas$s on the server, you need to deploy your dashboards on the #li$%iew Server.
. Association In #li$%iew two or more tables are associated on common eld names between the tables. +wo tables can be associated on a single column. If they are associated on more than one eld then Synthetic $eys will be created. -oo$ for how to associate tables when there are no common eld=names and also how to brea$ association between the tables
!. S"nthetic ke"s &hen you load multiple tables, then or more tables can get associated based on multiple eld names. +his will generate synthetic $eys=synthetic tables. #li$%iew recommends that synthetic $eys should be removed as they are resource intensive. -oo$ for ways to resolve synthetic $eys S"nthetic ta#le and S"nthetic ke"s gets created when there are more than one
common elds between the or more tables. #li$%iew associates tables based on the common eld names in the tables and if there is more than one common eld then #li$%iew creates synthetic tables. Synthetic $eys are not benecial in data model because they are resource intensive and may slow down calculations. +hey also ma$e data model hard to understand. Synthetic $eys should always be resolved.
Steps: •
I have loaded tables Products, 5rders and 5rderDetails
•
-oad the table and analy!e your data model in +able viewer and observe the )oins
ProductID and 7nitPrice and common in Products and 5rderDetails table and therefore created synthetic $eys. •
"a$e sure that +able associates only on the re3uired elds. since Products and 5rderDetails table are lin$ed on ProductID, we can remove 7nitprice from the table. 2ou can do so either by commenting 7nitprice or renaming it. -et us rename 7nitprice in Products table by using 8AS9
•
$. Loo%s &hen $eys between three tables in a data model form a circle,circular references are created.Avoid circular reference or loop by using loosely coupled tables or by aliasing one of the columns The r e a r e w to S wed i sh ca r br an ds, Vol vo nd a SAAB. Or , atl ea s, tt he r e u sed t o b e. . SAAB was ad me i n Tr ol l hät t an and Vol vowas –andst i l li s –madei n Got henbur g.
Tw o fic t i vef r i ends –Al ber t and Her ber t– l i vei n Trol l hät t an and Got henbur g, r esp ect i ve l y.Al ber t dr i ve s a V ol vo an d H er be r t dr i ves a AAS B.
I ft he abovei nf or mat i on i s t s or ed i n a t abul ar f or m, yo u get t he f ol l owi ng t hr ee t abl es:
Logi ca l l y,t heset abl es o f r m a ci r cu l ar r ef er ence : The first t wo t abl es a r e l i nke d t hr ough Ci t y;t he next t wo t hr ough Per so n; t he l astan dt he fir stt hr ough Car .
Fur t her ,t he da t af or ms a n an omal y:Vol voi mpl i es G ot hen bu r g;Got he nb ug ri mpl i esHer be r t ; an d Her be r ti mpl i es A S AB. Hen ce, Vol vompl ii es A S AB – w hi ch oe dsn’ t make nse se . Thi s m ea ns ha t t you have ambi guous e r su l t s r f om t he l og i ca li nf er ence- di ffe r ent r esu l t s d epe ndi ng on whet her yo u eva l uat e cl ockw i seor co unt er cl ockw i se .
I f yo u l oad t heset abl es n i t o Ql i kV i ew, t he ci r cu l ar r ef er encewi l l be i dent i fie d and yo u wi l l get t he f ol l owi ng dat a mode l :
Toavo i d a mbi guous e r su l t s,Ql i kV i ew mar ks no e o ft he a t bl es a s l “ oose l y co upl ed” , whi chmeans h t at t he l ogi ca li nf er enceca nnotpr opagat et hr ough t hi s a t bl e. I nt he docu ment pr op er t i es yo u ca n deci de whi cht abl e t o useas h t e l oose l y o cupl ed t abl e. You wi l l get di ffer ent r esu l t s r f om t he l ogi ca li nf er ence dep end i ng n o w hi ch you se. choo
So wha t di d I dowr on g? Whydi d I ge t a ci r cu l aref r er en ce?
I ti s n ot al way s o bvi ous w hy h t ey o ccu r , but when I enco unt er ci r cu l ar r ef er ence s Ial waysoo l k o f r fie l ds h t at ar e use d i n se ve r al droles i ffe r ent att hesam et i me.Oneob vou is exa mpl ei s f iyou ha ve a t abl e l i st i ng ext er nal or gani za t i ons a nd t hi s a t bl e i s u se d i n se ve r al r ol es:as C ust omer s,as S uppl i er s and as S hi pper s.I f yo u l oad t he t abl e onl y o nceand l i nk o t al lt hr ee f or ei gn ke y, s yo u wi l l mostl i ke l y get a ci r cu l ar r ef er ence . You need t o br eak h t e ci r cu l ar r ef er enceand t he so l ut i on i s o f co ur set ol oad once t he t abl e se ve r al t i me s, or each role.
I nt he ab ove dat a mode lyou ha vea si mi l ar case . Youcan t hi nk o f Car as“ Car pr odu ce di nt he ci t y”or “ Car t hat our f r i end dr i ve s. ”And yo u ca nt hi nk o f Ci t y a s C “i t y w her e ca ri s p r oduce d” or “ Ci t y w her e our f r i end l i ve s. ”Agai n, yo u sh oul d br eak h t e ci r cu l ar r ef er enceby o l adi ng a t abl et wi ce . One poss i bl e s ol ut i on i s h t e f ol l owi ng:
I n r eal l i f e ci r cu l ar r ef er ence s a r e not as o bvi ous a s h t i s o ne. I onceenco unt er ed a dat a model wi t h manyt abl es w her e Iat fir stco ul d no t fig ur e out what t o d o, bu t af t er so me a nal yzi ng,t he pr ob l em bo i l ed d ow nt ot hei nt er ac t i onbet wee n hr teefie l ds:Cust om er s,Mac hne is a ndDevi ce s.A cu so t mer ha d b ou gh t on e o r sever almach i ne s;a d evi ce co ul d b e co nn ect edt o so me o ft hemach i net ype s – bu t nott o al l ; an d a cust om er ha d bo ug ht som e de vces i . Hen ce ,t he devi cefie l d co ud l ha vet wo r ol es : Devi ce s ha tt t hecust om actually er had bought; and d ev i ce s h t at wo ftul d the machine h t at t he cu so t mer had b ought ,i . e. devi ce s h t at t he cu so t mer pot ent i al l y co ul d buy.Tw o r ol es.The so l ut i on w as t ol oad t he dev i cet abl et wi ceusi ng di ffe r ent names.
Bot t om l i ne: Avo i d ci r cu l ar r ef er ence s.But yo u pr obabl y a l r eady kn ew t hat …
&. Red'ce n'm#er of ta#les ( Always try to reduce the number of tables and )oins in your data model. 7se
"apping tables and Apply"ap function to clean up your data model as necessary
In #li$view it is always advisable to minimi!e the number of tables in the data model. "apping +ables are used in #li$%iew to clean up the data model. +ables with )ust columns can be removed and columns of that table can be mapped to another table. "apping tables are stored in a separate area in memory and used only as mapping tables during script e*ecution. After script e*ecution they will be automatically dropped.
). *nline ta#les +o create smaller reference tables,create Inline tables.
+. ,oins In #li$%iew result of a )oin between two tables is a single table. Eoins wor$s in a similar fashion as S#- )oins with e*ception being K00P. -eft Keep and ;ight Keep can be very useful
'xplaining (oins
)hose familier with manipulating data in %Q* or other +# tehnologies should have no problem understanding the different types of ,oins available in QlikView. +ut those who aren-t sometimes need a little explanation and it-s a topi that #-ve fond myself explaining often when training people. )he four primary logial ,oin types! *')! /#01)! #22'/ and O3)'/ are supported in QlikView. *et-s onsider the following eample tables and what the output for eah will be:
-ield2
-ield1
A
>
'
C
-ield2
-ield
2
F
G
As you an see! both tables ontain a olumn alled ield4 for whih some! but not all! of the values have a mathing entry in the other table. )he syntax for performing a ,oin in QlikView is relatively simple as follows: MyTable: LOAD
Field1, Field2 FROM myqvd1.qvd (qvd); LEFT JOIN
(MyTable)
LOAD
Field2, Field3 FROM myqvd2.qvd (qvd);
#t is important to note that QlikView links reords based on mathing field names in the two tables being ,oined. #n the example above! both tables ontain a field alled ield4 and thus QlikView will look for mathes aross these fields.
Also worth noting is the the table name defined in urved brakets. )his defines the previously loaded table whih the following table should be ,oined to. #t is not mandetory but it is onsidered best pratie to always speify a table to ,oin to inorder to avoid onfusion or mistakes. Without it! QlikView ,oins the table of data to the previously loaded table.
*') (O#2 #n a *') ,oin! all the reords from the first table are kept! and only those reords from the seond table that math a reord in the first table are kept. 3sing the above example tables! the output would be as follows:
-ield2
-ield1
-ield
A
>
'
C
2
5ou will notie that there is a blank entry in ield6. )his is beause no mathing reord exists in the seond table. 5ou will also notie that the reord in the seond table for whih there is no math in the first table has not been inluded.
/#01) (O#2 #n a /#01) ,oin! all the reords from the seond table are kept! and only those reords from the first table that math a reord in the seond table are kept. 3sing the above example tables! the output would be as follows:
-ield2
-ield1
-ield
'
C
2
F
G
5ou will notie that there is a blank entry in ield7. )his is beause no mathing reord exists in the first table. 5ou will also notie that the reord in the first table for whih there is no math in the seond table has not been inluded.
#22'/ (O#2 #n an #22'/ ,oin! only reords with a math aross both tables will be kept. 3sing the above example tables! the output would be as follows:
-ield2
-ield1
-ield
'
C
2
5ou will notie that there are no blank entries. /eords from either table for whih a math was not found have not been inluded.
O3)'/ (O#2 #n an O3)'/ ,oin! All reords will be kept and where possible! reords will be mathed. 3sing the above example tables! the output would be as follows:
-ield2
-ield1
-ield
A
>
'
C
2
F
G
5ou will notie that there are blank entries in both ield7 and ield6. )his is beause a mathing reord was not found in the other table.
When (oins 0o Wrong )he most ommon and easily made mistake when ,oining tables is not having at least one field named the same in both tables. When this ours! QlikView an-t make any mathes within the data and so outputs all possible ombinations of the reords in both tables. )his is known as the artesian produt. #f we take the above example but rename ield4 in the seond table by mistake so it no longer mathes the first table like this:
-ield2
-ield1
A
>
'
C
-ield22
-ield
2
F
G
When performing any of the ,oin types on these two tables! QlikView would reate the following result:
-ield2
-ield1
-ield22
-ield
A
>
A
>
2
A
>
F
G
'
'
2
'
F
G
C
C
2
C
F
G
)he produed table ontains all possible ombinations and therefor the number of rows it ontains will be the number of reords in the two tables multiplied together. #n this example 6 x 6 8 9 reords. )his isn-t the end of the world when data si&es are relatively small! but when mistakes are made ,oining tables ontaining millions of reords! the resulting table an take a very long time to alulate and be so large that it uses up all the physial /A and result in the mahine beoming unresponsive. Anyone working with QlikView on large datasets for very long will have learnt this lesson the hard way. # remember making a mistake whilst ,oinging a billion reord table to itself and had to explain red faed to the ustomer-s #) department why # needed them to restart the non;responsive server as it tried to alulate the result. A artesian produt isn-t always the result of a mistake though and an also be performed on purpose in advaned data transformations. or example! if # have a alendar table with a reord for eah day but what # really need is to expand it to have a reord for eah < hour shift in eah day! there is more than one way to approah the problem. # ould load the alendar into a temp table and then onatenate it 6 times into a resulting table denoting the shift eah time! or # ould reate a %hifts table ontaining a reord for eah shift and ,oin it to the alendar table providing no mathing field and thus purposfully ausing a artesian produt.
3sing (oins in QlikView by Josh Abbotton ay 46! 4=74 in QlikView
SQL deve l oper s sh ar et he co mmon ex per i enceof j oi ni ng r el at ed t abl es n i or der t o r et r i eve dat a se t s.The s ame h ol ds r t ue when w or ki ng wi t h d at a n i Ql i kV i ew . For t hose wi t h a SQL backg r ound, t he syn t ax o f rj oi ns n i Ql i kV i ew ar e sl i ght l y d i ffe r ent and ca n be a b i t di sco nce r t i ng w hen h t ey r e a u se d. I t ’ s e asy ot s ca r t chyo ur head a nd w onder why al lj oi ns n i al ll anguages a r e not c r eat ed exa c t l y h t e s ame. I n t hi s a r t i cl e, I wi l ll ead yo u t hr ough t he di ffe r ent t yp es o fj oi ns a nd how t o uset hesej oi ns n i a Ql i kV i ew appl i ca t i on. Fi r st , yo u need o t under st and h ow t abl es a r ej oi ned n i Ql i kV i ew. I n S QL, yo u sp eci f y h t e r el at ed co l umns r f om eacht abl et o be j oi ned. For i nst ance ,i f yo uj oi na R egi on t abl et o a Regi onCont actt abl e, yo u wr i t e so met hi ng si mi l ar t ot he f ol l owi ng: se l ect *
f r om Reg i on j oi n Regi onC ont act onReg i on . Reg i on I D = Reg i on Con t act . Reg i on I D I nt hi s n i st ance , yo uj oi nt he Regi on t abl et ot he Regi onCont actt abl e on t he Regi onI D co l umn t hat exi st s n i b ot ht abl es.I n Ql i kV i ew, a o j i ni s d one b ase d on fie l ds h t at have t hesam e n am e.Col um n n am es r e a n otact ua l l y speci fied ;i ft he y have hesam t e n am e, t hey o j i n, i f not ,t hey a r e not j oi ned. To j oi n, al lt hat i s n eeded i st he t y pe of j oi n. Fi r s t ,t her e i s h t e i nner j oi n. The defi ni t i on of an i nner j oi n i s h t at i tr et ur ns a l lr ows t hat mat ch a b se d o n i ke l fie l ds n i b oh t a t bl es.Her e s i an exa mpl e: Regi on: LO AD * I NLI NE [ Regi onI D, Regi onN am e 1, East 2, Wes t 3, Nor t h 4, Sout h ] ; I NNER JO I N ( Regi on) Reg i on Con t act : LO AD * I NLI NE [ Regi onI D, Cont act Nam e 1, Jo hn 2, Roger 5, Li nda ] ; I nt hi s si t uat i on, yo u havea Regi on t abl e wi t h e r gi ons 1– 4. The R egi onCont actt abl e has o nl y e r gi ons 1 , 2, and 5 . Theset abl es o j i n b eca uset he c ol umn R ‘ egi onI D’ ex i st s n i bot ht abl es,but wi l l onl y e r t ur nt he t wo mat ch i ng r eco r ds,1 and 2:
Nex ti st he l ef tj oi n. By d efi ni t i on, a l ef tj oi n r et ur ns al lr ows f r om t he fi r s tt abl e, and onl y mat ch i ngr ow s r f om t hese co nd ab tl e. H er e s i an exa mpl e: Regi on: LO AD * I NLI NE [ Regi onI D, Regi onN am e 1, East 2, Wes t 3, Nor t h 4, Sout h ] ; LE FTJO I N ( Regi on) Reg i on Con t act : LO AD * I NLI NE [ Regi onI D, Cont act Nam e 1, Jo hn 2, Roger 5, Li nda ] ; The onl y d i ffe r encebet ween t he l ef t and i nner j oi ni s h t e useof t he wor ds I ‘ner n ’ and ‘ Lef t ’ . n I h t i s ex ampl e, t abl e 1( Regi on) has R egi ons 1 – 4. Ta bl e 2( Regi onCont act ) has Regi ons 1 , 2, and 5. Si nce5 does n ot exi sti n Regi on, i ti s e l i mi nat ed f r om t he r esu l t i ng dat a se t . The Cont actName f or r egi ons h t at don’ t ex i sti n Regi onCont actwi l lr et ur na nul l va l ue.
Oppos i t e t he l ef tj oi n, i s h t e r i ght j oi n. By d efi ni t i on, t he r i ght j oi n r et ur ns a l l va l ues r f om t he se co nd t abl e, and onl y m at ch i ng va l ues r f om t he fir stt abl e: Regi on: LO AD * I NLI NE [ Regi onI D, Regi onN am e 1, East 2, Wes t
3, Nor t h 4, Sout h ] ; RI GHT JO I N ( Regi on) Reg i on Con t act : LO AD * I NLI NE [ Regi onI D, Cont act Nam e 1, Jo hn 2, Roger 5, Li nda ] ; Si nceonl y R egi ons 1 , 2, and 5 ex i sti nt he se co nd t abl e, t hesear et he onl y va l ues h t at wi l l be b r ought back . Si nce5 does n ot exi sti n h t e fir stt abl e, t he Regi onName wi l lr et ur n a nul l va l ue.
The nextj oi n t ol ook a ti s h t e out er j oi n. The out er j oi n r et ur ns al lr ows r f om t he first t abl e a nd a l lr ows r f om t he se co nd t abl e: Regi on: LO AD * I NLI NE [ Regi onI D, Regi onN am e 1, East 2, Wes t 3, Nor t h 4, Sout h ] ; OUTE R J OI N ( Regi on) Reg i on Con t act : LO AD * I NLI NE [ Regi onI D, Cont act Nam e 1, Jo hn 2, Roger 5, Li nda
] ; Thi s et rur ns 5r eco r ds,r eco r ds 3and 4 wi l lhave no Cont act Name, and r eco r d 5 wi l l hav e no Regi onN am e.
For any o ft hesej oi ns,i ft her e ar e no l i kefie l ds o tj oi n on, t hey c r eat e one r eco r df or eachr ow i n eacht abl e. So i ft abl e 1 has 1 0r ow s,and t abl e 2 has 1 0r ow s,and a j oi ni s per f or med wher et her ei s n ol i kefie l d name ( j oi ni ng fie l d) , 100 r eco r ds s i b er et ur ned, 1 f or eachco mbi nat i on of eve r y va l ue f r om t abl e 1 and t abl e 2. The l astt yp e of j oi ni n Ql i kV i ew ca n gi vedeve l oper s h t e mostt r oubl e. Conca t enat ei s a t yp e o fj oi nt hat i s si mi l ar t oa S QL UNI ON st at ement . Conca t enat e al l ows o r ws o t be pl ace d o n o t p o f eachot her or mer ged o t get her i nt o one a t bl e. Let ’ s say we h ave t wo t abl es,our Regi on t abl e, and anot her t abl e ca l l ed Ol dRegi on: Regi on: LO AD * I NLI NE [ Regi onI D, Regi onN am e 1, East 2, Wes t 3, Nor t h 4, Sout h ] ; CONCAT ENATE( Regi on) Ol dR egi on: LO AD * I NLI NE [ Regi onI D, Regi onN am e 5,Sou t hE ast 6,Nor t hW est ] ; I nt hi s e xa mpl e, yo ur et ur n a co nca t enat i on of t heset wo t abl es:
Li kena medcol um ns r e a p l ace d o n op t ofea ch t he or . S i nce bo t h co l um n n am es at mch, yo u s ee v al ues o f r al l fie l ds.Wher e d eve l oper s u r n n i t o p r obl ems s in i u nder st andi ng t hat Ql i kV i ew co nca t enat es a t bl es ha t t have exa ct l y h t e s ame n umber of co l umns w i t h exa ct l y h t e sa me n ames b y d ef aul t( or der does n otmat t er ) . Consi der a deve l oper t hat wi sh es o tr et ur nt wo t abl es,Regi on and Ol dRegi on. Theyr un t he scr i ptab ove wi t hout t heCon cat en ae: t Regi on: LO AD * I NLI NE [ Regi onI D, Regi onN am e 1, East 2, Wes t 3, Nor t h 4, Sout h ] ; Ol dR egi on: LO AD * I NLI NE [ Regi onI D, Regi onN am e 5,Sou t hE ast 6,Nor t hW est ] ;
The d eve l oper ach i eve s h t e sa me r esu l t as a bove : Onl y 1t abl ei s et rur ned. I f yo u do n ot wi sh ot cr ea t e o ne ab t l e,t he keyw or d N ‘ OCONCAT ENAT E’must be sp eci fied. Jo i ns a r e ve r y u se f ul i n Q l i kV i ew as h t eyyo ut o si mpl i f y yo ur dat a model by co mbi ni ng fie l ds r f om l i ket abl es.I t ’ s h el pf ul t o kn ow yo ur j oi ns,and l ear n how t o uset hem whi l e deve l opi ng o yur Ql i kV i ew sc r i pt .
. /rgani0e "o'r Scri%t ( 5rgani!e your scripts by creating +abs for related tables or logic. 7se comments to
ma$e your scripts logic easier to understand. All the tables should be named.;emember #li$%iew script e*ecution is from left to right and top to bottom. Any referenced tables should be created before being referenced.
1. aster calendar
"aster Calendar in #li$%iew F Eune, ?> Chandraish Sinha
In any Dashboard,+ime is an important factor. 7sers will always be interested in viewing the data by time period and also will be interested in performing comparitive analysis between time periods. In a data warehouse, a +ime dimension table is usually present, which )oins to the fact table and produces results.In some situations, time dimension is not present but a date eld is present in the fact table.In such scenarios, it is a best practice to
create "aster calendar by ta$ing the date eld in the fact table. +his "aster table will contain all the combinations of date and time and will )oin to the fact table. In this blog i will discuss how to create a "aster calendar based on date eld in the fact table.
In my previous blogs, i have loaded Sales5rderHeader table. +his table contains 5rderDate eld. 2ou can always create +ime values by applying date time functions on the 5rderDate column 2ear5rderDate1 As 5rder2ear "onth5rderDate1 As 5rder"onth +his will give you 2ear and "onth values but it will give you only the values which are present in the database. If say, for e*ample, there were no 5rders in "arch then this method will not show the "arch month in the list bo* and date will not be continous. +o resolve this problem, we will create "aster Calendar.
Steps: >. Create or set the value of "in date based of the 5rderDate in the Sales5rder+able. +his can be done either by hardcoding the start date or by ta$ing the rst value of the 5rderDate by using Peek34
Peek() will give the value o the !rder"ate in the frst record -et var"inDate J
. Create or set the value of "a* date Peek() will give the value o the !rder"ate in the last record -et var"a*Date J ,(5rderHeader(11 . :enerate the rows in the calendar table by using Autogenerate. Autogenerate in #li$%iew is used to generate rows automatically. +empCalendarL -oad dateMvar"inDate1 / rowno1 >1 As +empDate Autogenerate Mvar"a*Date1 Mvar"inDate1 / >
F. Create "aster Calendar "asterCalendarL -oad +empDate As 5rderDate, &ee$+empDate1 As &ee$, 2ear+empDate1 As 2ear, "onth+empDate1 As "onth resident +empCalendar
#li$%iew application consists of parts %isuali!ations and Data model. 2our visuali!ation will display the underlying data.+herefore creating a robust Data model is $ey to any successful application.
1. 5oncatenate in QlikView In #li$%iew, if the number of elds and eld names of two or more tables are same then the tables are 5oncatenated into one table. +here are many Navors in Concatenate li$e Automatic Concatenate,6orced Concatenate and
Concatenate and >O 5ctober, ?> Chandraish Sinha
In #li$%iew, if the number of elds and eld names of two or more tables are same then the tables are 5oncatenated into one table. It usually happens when you are loading tables from di4erent datasources and don(t reali!e that eld names and eld numbers in di4erent tables are same. After the
dataload you e*pect to see two separate tables in table viewer but instead see only one. 5oncatenate happens in di4erent ways.
>. Automatic Concatenation . 6orced Concatenation .
*n this Part 1 i will cover A'tomatic 5oncatenation A'tomatic 5oncatenation
As stated above,when eld names and eld numbers of or more tables is same then the tables are concatenated into one table. 5rder of the columns in tables does not matter. Also +he Sum of records in the resulting table is the Sum of the number of records in +able > and +able . -et us load rst table and see it in the table viewer
As you can see that this table has following F rows.
-et us now load tables, with same name and number of columns. +able Cust> has F rows and table Cust has rows. 5rder of columns are di4erent. 5bserve +able viewer and number of rows in the resulting table.
As you can see the number of rows in the resulting table is rows. +he Sum of records in the resulting table is the Sum of the number of records in +able > and +able .
In this Part , you will see 6orced Concatenation and how to prevent Concatenation i.e.
If two or more tables do not have e*actly same name and number of elds, it is still possible to concatenate them by using concatenate $eyword before the load statement.
-et us load tables with di4erent sets of elds
Concatenation do not occur as +ables have di4erent set of elds.
5bserve that the tables are concatenated and numbers of rows is i.e. Sum of rows in +able> and +able.
Preventing 5oncatenation
If the eld names and number is same in or more tables them #li$%iew performs an automatic concatenation but it is possible to prevent this automatic concatenation by using 6o5oncatenate -et us load the same tables as in Part> i.e. +able Cust> and Cust. +hese tables have same set of elds so they should get concatenated but this time load them by using
+able viewer shows tables. Automatic concatenation was prevented by using
>. Automatic concatenation occurs when the name and number of elds are same in or more tables . 6orced concatenation is done by using Concatenate $eyword. It will concatenate tables even if they do not have same set of elds .
your data model. +hese 6act tables should be of same granularity
2. Link 8a#le in QlikView &henever you will hear about Concatenate, you will hear about -in$ table as well. -in$ tables are also used when you have to add multiple fact tables in your data model. +hese fact tables may be of di4erent granularity and associated to same or di4erent dimension tables.-in$ table is a means to resolve synthetic $eys. -in$ table contains the common elds from multiple tables.
8he agic of link 8a#le In Data warehousing world, many a times you come across a situation where you have to handle multiple 6act tables. Star schema usually have a single 6act in the center and dimensions surrounding it but some times you have a situation where you have more than one 6act table.
I you want to learn more about #acts and $tar schema% &lease visit my earlier blog htt&'www.learnallbi.comdimensionandact. In this blog i will discuss about how to handle multiple fact tables in #li$%iew data modeling.
Link ta#le vs 5oncatenate &hen you have multiple 6act tables in #li$%iew, it can be handled in ways, by using concatenate or by using -in$ tables. If the granularity and columns in the fact tables are same then you can use Concatenate which will merge the tables into one and resulting table will have the sum of rows of the two tables. 7se -in$ table, when the granularity of the facts tables are di4erent and when they are )oined to di4erent dimensions. Concatenate and -in$ +ables are ways to resolve synthetic $eys which formulate due to the presence of multiple fact tables.
Link 8a#le e9am%le +o e*plain the concept of -in$ table, I will load few fact tables and dimension tables.
if you load these tables, you will get synthetic elds in your data model. +hese synthetic $eys are formed since we have multiple 6act +ables and these fact tables are sharing the same dimensions.Since these fact tables are )oining to the same dim tables they have duplicate=common elds.
Resolving S"nthetic :e"s 'sing Link ta#le
+o resolve these synthetic $eys we will L Create a composite $ey. -in$ table can connect to the srcinal fact tables using this composite Key -oad all the common elds in one table called -in$ table Drop these elds from the srcinal tables. -et(s see these steps in screen shots belowL
Creating composite $eys
Creating -in$ table. -oading common elds from the srcinal 6act tables.
Drop elds as we no longer need these elds. After following the above steps and loading the data , you will get the following data model. As you will notice, -in$ table is in the center. -in$ table contains all the common elds and -in$ table is lin$ed to other fact tables using the Key eld.
-in$ +able is a very useful way to resolve synthetic $eys when multiple fact tables are present in the data model.
2ou should always load Distinct records while creating -in$ table. Also if the Key eld=composite eld contains several individual elds then it is good to create Key eld using Auto number 1 function li$e the one below Auto
. Partial Load Partial load is used when you want to load )ust one table in your data model=script without reloading all the other tables. 6or e*ample, you are in development phase and your script contain >? tables but you want to )ust reload one table since data in table changed or the structure of this table has changed. If you perform normal load then all >? tables will be loaded that may ta$e time. 'ut with Partial load you can )ust load one table. +o perform partial load you have to pre* your load statement with ADD or ;0P-AC0 $eywords. Pre*ing your load statement with ADD will append the new records. Pre*ing your load statement with ;0P-AC0 will drop the e*isitng table and create a new table. 8i%7 +o perform Partial load, use 6ile menu @VPartial load or Ctrl / Shift / ;. Partial
load functionality is useful in development. ;emove ADD or ;0P-AC0 when your development is completed and you are migrating your application on the server.
!. 5ross ta#le in QlikView -oad statement is pre*ed with Cross+able when you want to load a Cross+able. A Cross+able is a table structure with 5rthogonal list of headers. If a Cross+able is loaded as a normal table then each of the column will be loaded separately as an individual dimension.Performing aggregation on such a table will be diWcult. Also it will consume lot of memory. Cross+able pre* will transform columns into rows. 5ross 8a#le is a table with 5rthogonal list of headers. 5rthogonal simply means at
right angles. &e come across cross tables everywhere in our daily lives.
*ichael +ordan is the greatest bas$etball player of our times. I am a big fan of "ichael Eordan. +o e*plain the concept of Cross table, i will ta$e a sample of "ichael Eordan(s regular season statistics.
"ichael Eordan Stats Source espn.go.com +his is a cross table because it contains 5rthogonal lists of headers Season,+eam and Categories. if this is loaded in #li$%iew in a normal fashion, it will create separate list for each of the columns. After the data load, it will loo$ li$e
If the Cross table is very large with huge number of 5rthogonal headers then it will ma$e the application very heavy because each of the column in the cross table will be loaded separately. If you view this table in the table viewer, it will loo$ li$e
In #li$%iew you have to load a Cross+able by using Cross+able transformation pre* load statement with Cross+able synta*1. It will then create one column for Season,5ne for +eam ,5ne for each of the Category and 5ne for Data. Loading Data # " 'sing 5ross8a#le transformation
+o load a crosstable, start with similar steps as loading +able le=e*cel le, clic$ on 8+able les9
Clic$ on 80nable +ransformation step9 to apply Cross+able transformation
Clic$ on 8Cross+able9 under le parameters
Select the #ualier eld=s, Attribute eld and Data eld. #ualier elds are the columns to the left. 2ou can decide which columns you want to treat as 3ualiers.
-oaded Crosstable will loo$ li$e the following , which is one column for Season,5ne for +eam ,5ne for each of the Category and 5ne for Data.
Cross+able -oad script will loo$ li$e the following.
After the data load, If you see the +able viewer , it will loo$ li$e
6ields will be loaded in the following fashion
$. Section access Security is an important part of an application. Section access is used to provide data level security to your application. 'y using Section access you can limit what data
authori!ed users can see. Section access is dened in script editor as a hidden script. +he access control data can be managed through +e*t les,databases or Inline tables.
&. ;inar" Load &hen we tal$ about Section access , we tal$ about 'inary -oad as well. 'inary load is used when you want to load the script part of another 3vw le. 2ou can have only one 'inary load in a 3vw and it has to be the very rst statement in your script.2ou can only load one 3vw in your document. It loads )ust the script part, visuali!ation is never loaded. It is useful when applying security using Section Access. 2ou can develop security guidelines in a separate #%& and then add that #%& using 'inary -oad in all the other documents.
). *nterval atch Interval match function is used with -oad statement for lin$ing the discrete values to one or more numeric intervals.It can be used for e*ample, in scenarios where you have tables one table containing Shift intervals li$e Start and 0nd and another tables containing )ust the +ime. 2ou can use Interval "atch function to lin$ these tables and nd out in which +ime interval these Start=0nd shifts occur. Interval "atch e*tended synta* is used to handle the Slowly changing dimensions.
Interval *atch and $lowly changing dimension In these blogs i have made an attempt to cover all the basic building bloc$s of #li$%iew data modeling. Continue e*ploring and learning the awesome world of #li$%iew.