Sie sind auf Seite 1von 19

Getting Started with QlikView Part XIII Addressing the Data model issue (Synthetic Key issue)

Descri tion! BISP is committed to provide BEST learning material to the beginners and advance learners. In the same series, we have prepared a complete end-to end Hands-on Beginners G ide !or "li#view $eport, S%nthetic #e% iss e, S b!ield & nction. The doc ment !oc ses on script editor. 'oin o r pro!essional training program and learn !rom e(perts.

Histor%) *ersion ../ ../ +escription ,hange Initial +ra!t $eview1/ - thor S rbhi sah $a2# mar 3 P blish +ate 0/st - g 0./0 04th - g 0./0

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page /

Table of Contents
Table o! ,ontents......................................................................................................................... 0 /5-spects related to reloading the application)............................................................................ 6 05The Script Editor........................................................................................................................ 7 0./58en and toolbar................................................................................................................ 7 0.05 Script pane........................................................................................................................ 9 0.65 Tool pane.......................................................................................................................... 9 0.75 Script statement................................................................................................................. 9 65 :oading the aircra!t in!ormation............................................................................................... ; 75S%nthetic #e% iss e................................................................................................................. /6 The problem generated d e to s%nthetic #e%........................................................................../7 ............................................................................................................................................... /7 ;5,oncatenate statement........................................................................................................... /9 <5 'oin statement........................................................................................................................ /< =5S b!ield & nction..................................................................................................................... /= S b!ield ! nction are sed !or splitting the !ield via s b!ield ! nction we can split two !ields within a single !ield..................................................................................................................... /=

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page 0

1)

Aspects related to reloading the application:

-s we !amiliar abo t the reload ! nction is to load the data !rom di!!erent data so rces into the "li#*iew data model. B% de!a lt, when "li#*iew enco nters errors d ring the reload o! a doc ment, it a tomaticall% closes the doc ment and reloads the last saved version o! the !ile > data. It can be a !r strating e(perience when %o have 2 st written a lot o! script, onl% to see all o! it lost beca se %o !orgot a semicolon somewhere and didnt save the script which %o have written all this time. -nd %o !orgot to save the script be!ore reloading the data. ?ne wa% to avoid this problem is b% alwa%s !irst saving %o r script be!ore reloading. This can be done b% /5 &ile @ Save Entire +oc ment !rom the men , 05 ,trl A S, 65 ,lic#ing on the Save icon in the toolbar, 75 -nother more sa!e wa% is to set in "li#*iew to a tomaticall% save the !ile be!ore each reload. To do this, close the script editor and open the Bser Pre!erences men b% selecting Settings @ Bser Pre!erences !rom the men , or b% pressing ,trl A -lt A B. In the men , select the Save tab and tic# the chec#bo( labeled Save Be!ore $eload. It is also advisable to tic# the chec#bo( Bse Bac# p and set the !ield Ceep :ast Instances to 9. This last option ens res that the last 9 versions o! the "li#*iew !ile are #ept as bac# p.

Then-@-ppl%-@o# www.bispsol tions.com www.bisptrainigs.com www.h%periong r .com Page 6

2)

The Script Editor

Script editor is the portion where the script are written and tables are loaded in application. This is mainl% termed as the DHeart o! "li#*iewE. -ll the ET: wor# is done here.

The script editor consists o! the !ollowing areas) - men bar - toolbar - script pane - tool pane

2.1)Menu and toolbar


The men o!!ers a wide range o! options &ile F $eloadG $ ns the entire script to reload the data &ile F Save Entire +oc mentG Saves the entire doc ment, not 2 st the Tab F -dd Tab G script "li#*iew scripts can be organiHed sing tabsI this ! nction adds a new tab Tab F $enameG $enames the c rrentl% selected tab Tab F PromoteG 8oves the c rrentl% selected tab to the le!t Tab F +emoteG 8oves the c rrentl% selected tab to the right

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page 7

2.2)

Script pane

This is the main wor#ing area o! the script editor. Jhen a new "li#*iew data model is created, the new script is pop lated with a 8ain tab and a !ew lines where n mber interpretation variables are added. These lines tell "li#*iew how to interpret vario s n mbers and are generated a tomaticall% based on %o r operating s%stem settings.

2.3) Tool pane

The +ata tab gives "* the !le(ibilit% to get > connect to di!!erent data so rces to get data. The & nctions tab gives a categoriHed overview o! the script ! nctions available in "li#*iew. The *ariables tab shows ser and s%stem variables. This tab is pop lated a!ter each reload, so in a new doc ment it will be blan#. The Settings tab contains some additional settings with regards to s%stem access and password scrambling.

2.4) Script state

ent

- "li#*iew script is made p o! a seK ence o! :?-+ > S": statements. These statements are t%picall% sed to either manip late the data, or to conditionall% control the wa% in which the www.bispsol tions.com www.bisptrainigs.com www.h%periong r .com Page 9

script is e(ec ted. &or e(ample, we ma% want to combine two tables together, or s#ip over a part o! a script i! a condition is not met. Je loo# some other actions which we can per!orm thro gh the "li#*iew

Here %o can see in the script editor window the script is here !or the table -ircra!t Gro ps and -ircra!t T%pes I! we erase the script !rom here this will disappear the data !rom both tables in the sheet. :oo# here the both !ields are shown as L navailable5.

3) !oading the aircraft infor

ation

:oading o! aircra!t in!ormation sing these steps) Step/) ,hoose the !ile !or pload b% clic#ing on -@ Table !iles in the Tool Pane @ Browse the location o! the partic lar !ile which we want to load, select D-ircra!tMBaseM&ile.csvE -@ ?C basicall% this !ile consists o! all the pdates prior to the %ear 0./.. Je have loaded it in to the application. www.bispsol tions.com www.bisptrainigs.com www.h%periong r .com Page ;

Step 0) 3ow the table will be loaded in the "li#*iew

The "* &ile JiHard has identi!ied the !ile t%pe as D+elimitedE, which we are loading @ &inish.

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page <

Step 7)

Here the script is loaded in the table b t the name o! the !ields name are not properl% maintained Lso as to maintain 2oins between the tables5 so we rename the !ields b% sing Nas #e%word. O-ircra!t T%pesP) :?-+ -,MTQPEI+ as OR-ircra!t T%pe I+P, -,MG$?BP as OR-ircra!t Gro p T%peP, SS+M3-8E as O-ircra!t 3ameP, 8-3B&-,TB$E$ as O-ircra!t 8an !act rerP, :?3GM3-8E as O-ircra!t 3ame & llP, SH?$TM3-8E as O-ircra!t 3ame -bbreviatedP, BEGI3M+-TE as O-ircra!t Begin +ateP, E3+M+-TE as O-ircra!t End +ateP &$?8 O..S+ata &ilesS,S*sS-ircra!tMBaseM&ile.csvP Lt(t, codepage is /090, embedded labels, delimiter is TIT, msK5I Step 9) 3ow we are moving thro gh o r ne(t table which is D-icra!tM0./.MBpdate.csvE which gives the in!ormation abo t the pdates o! 0./. %ear and later.

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page =

Step ;) 3ow the table will be loaded @ &inish

Step <) Then $ename the col mns o! the table D-ircra!tM0./.MBpdateE sing Nas #e%word as shown here. O-ircra!t T%pes 0./.P) :?-+ -,MTQPEI+ as OR-ircra!t T%pe I+P, -,MG$?BP3-8E, SS+M3-8E as O-ircra!t 3ameP, 8-3B&-,TB$E$ as O-ircra!t 8an !act rerP, :?3GM3-8E as O-ircra!t 3ame & llP, SH?$TM3-8E as O-ircra!t 3ame -bbreviatedP, BEGI3M+-TE as O-ircra!t Begin +ateP, E3+M+-TE as O-ircra!t End +ateP &$?8 www.bispsol tions.com www.bisptrainigs.com www.h%periong r .com Page 4

O..S+ata &ilesS,S*sS-ircra!tM0./.MBpdate.csvP Lt(t, codepage is /090, embedded labels, delimiter is TIT, msK5I Step =) Then the Table -ircra!t Gro p will be loaded in the "li#*iew application. This &ield contains the in!ormation abo t -ircra!t Gro p I+ ,-ircra!t Engine t%pe and -ircra!t n mber o! Engine. &or this browse the location and open the partic lar !ile.

Step 4)3ow the data will be loaded in application-@ &inish

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page /.

-ircra!tMGro pt%pe

-ircra!tM0./.MBpdate

Step /.) Then the script will be loaded in the script editor. 3ow here is the iss e that two col ms contains the same val e b t the% got di!!erent name !or identit%.

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page //

So, its ver% illogical to avoid this as it will have large no o! records. Je sho ld red ce o r data as m ch as possible. So that we can easil% manage o r data and can red ce the e(tra statement sing Nas #e%word which can be applied in the both table. -nd 2oining these 0 tables with this col mn > !ield name.

we sed as -ircra!t Gro p Id in R-ircra!t Gro p T%pe these both considered as a single col mn. 3ow loaded the data. Have a loo# at the table viewer.

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page /0

:oo# here the !ield Us%n/ Table which we have not import b t e(ist in the table viewer window. This is the S%nthetic #e% which is a to-maticall% generated.

4)S"nthetic #e" issue


S%nthetic table and S%nthetic #e%s gets created when there are more than one common !ields between the 0 or more tables. "li#*iew 2oin tables based on the common !ields names in the table and i! there is more than one common !ield then "li#*iew creates S%nthetic tables. S%nthetic #e%s are not bene!icial in data model beca se the% are reso rce intensive and ma% slow down calc lations. The% also ma#e data model hard to nderstand. S%nthetic #e%s sho ld alwa%s be resolved. :oo# the three tables which we have loaded in the table having man% !ields common as we see -ircra!tMBaseM&ile having almost !ields similar to -ircar!tM0./.MBpdate since in table !ield and these two contain one !ield similar to the table -ircra!t Gro p is -ircra!t Gro p I+.

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page /6

The proble

generated due to s"nthetic #e"

&or loo#ing the problem create a m ltibo( -@right clic# on the sheet -@go to new sheet ob2ects -@m ltibo(.

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page /7

3ow !ive !ields are selected those are -ircra!t 3ame,-ircra!t n mber o! engine,-ircra!t engine t%pe -ircra!t beging date,-,MG$?BP3-8E.now-@-ppl%-@o#.

loo# here the data on -,MG$?BP3-8E !ield disappeared d e to generation o! s%nthetic #e%s here we have two wa%s to resolve this iss e. Bsing concatenate statement Bsing 2oins

$)Concatenate state

ent

The ,?3,-TE3-TE statement is also a pre!i( to the :?-+ statement, b t instead o! matching and merging rows between tables, this statement appends the rows o! one table to another table. E(ample :oo# here we have table Table/ and Table 0

,oncatenate appends the rows o! one table to another. ,oncatenate never merges an% rows. The n mber o! rows in a concatenated table is alwa%s the s m o! the rows !rom the two inp t tables. ,?3,-TE3-TE LTable/5 :?-+ V $ESI+E3T Table0I

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page /9

$ows are li#e Ce% val es and are not merged together. The rows !rom Table0 are simpl% appended to Table/. Beca se the tables have di!!erent !ields, rows will have n ll val es !or the !ields !rom the WotherW table.

Here we want the whole in!ormation in this the table -ircra!tM0./.MBpdate contain in!ormation o! 0./. and -ircra!tMBaseM&ile in!ormation be!ore 0./. we want to per!orm -irca!tMBaseM&ileG -ircra!tMBaseM&ileLprevio s5A -ircra!tM0./.MBpdate we want that the data o! 0./. append to the base !ile.

-@$eload the table-@go to the table viewer

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page /;

&rom the table viewer window the table -ircra!tM0./.MBpdate disappear and concatenates into the table -ircra!tMBaseM&ile.

%) &oin state

ent

The '?I3 statement is a pre!i( to the :?-+ statement. It is sed to 2oin the table that is being loaded to a previo sl% loaded table. The two tables are 2oined sing a nat ral 2oin, this means that the col mns in both tables are compared and the 2oin is made over those col mns that have the same col mn names. This means that i! m ltiple col mns are shared between tables, the match will be made over the distinct combinations o! those col mns. E(ample we have 0 table Table/ and Table 0

3ow the 2oin will res lt ,?3,-TE3-TE LTable/5 :?-+ V $ESI+E3T Table0I

Here we have two tables as -ircra!tMgro p and -ircra!tMBaseM&ile in this we have previo sl% seen that the data in the 0 !ields as -ircra!t Gro p I+ and R-ircra!t Gro p T%pe is same so we want to merge this row o! the table -ircra!tMgro p

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page /<

This will merge the row in the table -ircra!tMbaseM&ile.

')Subfield (unction
S b!ield ! nction are sed !or splitting the !ield via s b!ield ! nction we can split two !ields within a single !ield. :oo# the !ield -,MG$?BP3-8E o! -ircra!t base table

-nd these two !ields o! table -ircra!tMGro p

Here the !ield -,MG$?BP3-8E !rom table -ircra!tMBaseM&ile covers the in!ormation o! -ircra!t Engine T%pe and -ircra!t 3 mber ?& Engines o! table -ircra!t Gro p individ all% so we can split these two cplo mns within a single table. -,MG$?BP3-8E G -ircra!t Engine T%peA-ircra!t 3 mber ?& Engines This ! nction is ver% case sensitive, in !ield -,MG$?BP3-8E in!ormation separated b% commaL,5 in s%nta( as we are loading the .csv !ile which is a comma separated !ile. SBB&IE:+L-,MG$?BP3-8E,T,T/5 as -ircra!t Engine T%pe SBB&IE:+L-,MG$?BP3-8E,T,T05 as -ircra!t 3 mber ?& Engines are n mbered as / and 0 to identi!% the !ields which are going to get split.

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page /=

3ow reload the table and go to the table viewer window. :oo# here the s%nthetic #e% resolved and data managed in !ormatted wa%.

www.bispsol tions.com

www.bisptrainigs.com

www.h%periong r .com

Page /4