ins v w-to - static.packt-cdn.com · ins v w-to 3 for this game, we are going to use the qlikview...

16
Instant QlikView App Development How-to 1 Analyzing movies example (Simple) QlikView 11 is designed to use a methodology of Social Business Discovery to enable users to collaborate on their discoveries. But before we can collaborate and jointly interpret our findings, we need to have some experience and ideas of the types of analysis we can perform. This recipe will give a simple introduction to the uses of QlikView. Powerful business insight comes not just from data or from what one person sees and thinks. It comes from the combination of varied viewpoints, conclusions, and compromises of people both formally and informally. Social Business Discovery builds on what QlikView calls their direct discovery feature. The direct discovery feature is a built-in capability where in-memory and direct discovery datasets can be analyzed together, even on the same chart. The users can make selections on either of the datasets, the in-memory dataset or the direct discovery dataset, and see what is associated and not associated with the standard QlikView association colors; green, gray, and white (or customize the interface to use colors of their own choice). Then the user can create charts that will help them analyze data from both datasets together. The following quote is taken from the QLIKVIEW 11.2 DIRECT DISCOVERY FAQ PDF file: QlikView Direct Discovery enables users to perform business discovery and visual analysis against any amount of data, regardless of size. With the introduction of this unique hybrid approach, users can associate data stored within big data sources directly alongside additional data sources stored within the QlikView in-memory model. QlikView can seamlessly connect to multiple data sources together within the same interface, e.g. Teradata to SAP to Facebook allowing the business user to associate data across the data silos. Specifically, in list boxes, selected items are highlighted in green, possible items are highlighted in white, and excluded items turn gray with white lettering.

Upload: others

Post on 22-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

1

Analyzing movies example (Simple)QlikView 11 is designed to use a methodology of Social Business Discovery to enable users to collaborate on their discoveries. But before we can collaborate and jointly interpret our findings, we need to have some experience and ideas of the types of analysis we can perform. This recipe will give a simple introduction to the uses of QlikView.

Powerful business insight comes not just from data or from what one person sees and thinks. It comes from the combination of varied viewpoints, conclusions, and compromises of people both formally and informally.

Social Business Discovery builds on what QlikView calls their direct discovery feature. The direct discovery feature is a built-in capability where in-memory and direct discovery datasets can be analyzed together, even on the same chart. The users can make selections on either of the datasets, the in-memory dataset or the direct discovery dataset, and see what is associated and not associated with the standard QlikView association colors; green, gray, and white (or customize the interface to use colors of their own choice). Then the user can create charts that will help them analyze data from both datasets together. The following quote is taken from the QLIKVIEW 11.2 DIRECT DISCOVERY FAQ PDF file:

QlikView Direct Discovery enables users to perform business discovery and visual analysis against any amount of data, regardless of size. With the introduction of this unique hybrid approach, users can associate data stored within big data sources directly alongside additional data sources stored within the QlikView in-memory model. QlikView can seamlessly connect to multiple data sources together within the same interface, e.g. Teradata to SAP to Facebook allowing the business user to associate data across the data silos.

Specifically, in list boxes, selected items are highlighted in green, possible items are highlighted in white, and excluded items turn gray with white lettering.

Page 2: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

2

Getting readyYou may have played the game Six Degrees of Kevin Bacon or at least heard of it. It is a game based on the sociological theory of six degrees of separation, the idea that everyone is on average approximately six steps away by way of introduction, from any other person in the world. Social psychologist Stanley Milgram put the idea of six degrees of separation to the test in the 1960s by asking volunteers to get a message to a random individual living near Boston. The test subjects were asked to send the message to a friend who was more likely than they to know the target person. It took an average of 5.2 people in the chain to get the letter to the target, so because it was over five, the theory rounded up to six degrees apart from any other person on the globe.

Duncan Watts expanded the theory of six degrees of separation to Network Theory, the scientific field that examines how networks form and how they work in society. Network Theory covers many subjects, including:

• How people interact socially• How diseases spread• How people find jobs• How aspects of the World Wide Web operate

Using this theory and the QlikView Movie Database available from QlikView in the Getting Started examples section; we are going to play the game Six Degrees of Kevin Bacon as an analysis example. If we understand how to analyze data on this smaller scale, then it should make it easier for us to see ways of using the expanded and refined version, Network Theory, to analyze our own data in ways we might not have seen before.

How to do it...We start by opening QlikView 11. This time at the start screen, scroll down to the Examples section and select Movie Database. Note that it claims to have over four thousand movies. With approximately four hundred movies produced each year, currently, that represents the equivalent of ten years of recent movies, but the movies in the QlikView Movie Database range from Tillie's Punctured Romance (1914) to movies released in the year 2008. Therefore, we know it is not a comprehensive list of movie titles, directors, and actors.

If you are interested in verifying this for yourself, jump to the Analysis tab of the QlikView Movie Database.

Page 3: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

3

For this game, we are going to use the QlikView Model sheet, the fourth tab from the left.

Here we can start with the actors. It so happens that when I was a child, the actor Joseph Cotten came over to my aunt's house. I was allowed to sit on the floor and listen to his stories about Hollywood. So this means that I am one degree of separation from the actor Joseph Cotten. But how far does that put me from Kevin Bacon? Since we know from our preceding analysis that this is not a comprehensive database, first we need to make sure the actors we are interested in are actually in the database.

Working from Kevin Bacon, we use the built in search functionality to select Kevin Bacon. The Search icon looks like a little magnifying glass.

Page 4: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

4

In the next screenshot, we can see in white in the center list box, the movies that Kevin Bacon has worked in which are present in the QlikView Movie Database. The list shows:

• Animal House• National Lampoon's Animal House• Delta Gänget (1978)

The preceding names are of the same movie, the last being the Swedish title. In the following list, note how the "The" in front of The Woodsman is moved to the back to make alphabetical sorting correct.

• Apollo 13 1995• Hollow Man 2000• JFK 1991• Mystic River 2003• The Woodsman 2004.

From this we can verify that the Movies Database is incomplete. If we check the Internet Movie Database (www.IMDb.com) for example we can see that this database is missing several movies that Kevin Bacon appeared in, such as Footloose (1984), Tremors (1990), A Few Good Men (1992), and Stir of Echoes (1999). IMDb.com shows that to the date of this writing, Kevin Bacon has appeared as an actor in 75 movies, so if we were depending upon the QlikView Movie Database for an important analysis, we would need to make sure we updated the data from several sources to get complete information for our analysis.

But for purposes of this analysis, we are just trying to connect the author to Kevin Bacon in six or less links. Now we will search on Joseph Cotten (1905-1994) in the Actors list box to make sure he is in the database.

Page 5: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

5

We can see that the QlikView Movie Database has 19 movies listed that Joseph Cotten has worked in, among them Citizen Kane (1941), The Third Man (1949), Soylent Green (1973), and Airport 77 (1977). This does not include many of the 132 titles shown in IMDb.com. Most importantly, he is in the QlikView Movie Database for our analysis.

Now, we will select all of the directors that have worked with Joseph Cotten by right-clicking on the Directors list box and choosing Select Possible. If we edit the list box by right-clicking and choosing Properties instead, we could chose to put the Select Possible icon on the List Box toolbar. The checkbox to add this icon is in the Caption tab under the Special Icons section as shown in the following screenshot:

The Select Possible icon looks like a spreadsheet with a single checkmark. See the following screenshot for reference:

Page 6: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

6

Also, while we are in the Caption tab, we notice how the title with the count of the number of directors is added to the List Box toolbar:

=Minstring({<Index = {5}>} [$(vLanguage)]) & ': ' & Count (DISTINCT Director)

The following function will give us the same results, but is not as dynamic and will not automatically convert the title to another language. On the other hand, this is easier to read and understand without needing to understand Visual Basic coding.

='Director ' & ': ' & Count (DISTINCT Director)

The preceding screenshot shows how we select all possible directors who have worked with Joseph Cotten:

After selecting all the directors who have worked with Joseph Cotten, we clear the Actor selection by clicking on the icon—that looks like an eraser—to show all the names of the actors that have worked with the directors who have worked with Joseph Cotten. The names of these actors are now shown in white. We also see that the 11 directors selected now have 193 movie titles listed in the center section in white and the possible actors total shows 2474. We scroll down the list of actors and see that Kevin Bacon does not appear in the white highlighted list. We are going to need to find an overlapping connecting actor. An actor that has worked for two different directors, one who has worked with Joseph Cotten and one who has worked with Kevin Bacon.

Page 7: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

7

Now George Cukor has directed 52 films in the database and Alfred Hitchcock directed 68 so chances are excellent that there is overlap, but that also gives us a lot of films and actors to search through to find our link. Let us start with Jerry Jameson, the first director with only two movies on the list instead. This should narrow down our search. And if we don't find a connection there, we can always broaden our search.

Page 8: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

8

How it works...Now we will see how this simple analysis works to find the actual degrees of separation.

We can see that Jerry Jameson is associated with two movies and 23 actors; this is a reasonable number to search through and try to match up with another actor who has worked with Kevin Bacon. Because we would like to have the list available once we have changed selections, we right-click the list of actors and choose Export to Excel in the menu. This menu item can also be added as an icon to the list box.

The Export to Excel icon looks like the two letters XL. Excel should open and show the entire list of actors with the 23 associated with Jerry Jameson highlighted in white and the non-associated actors are highlighted in gray.

We now have a backup list of the actors who have worked with the director Jerry Jameson since we will continue to make changes to our dynamic lists.

Next select the 23 actors in QlikView by right-clicking in the Actors list box and clear the Directors list box by clicking on the Clear icon in the Directors list box. This shows us the movies and directors who have worked with these 23 actors. We could highlight all the possible movies and make sure both Kevin Bacon and Joseph Cotten show up on the list of Actors, but that won't tell us who the actor is connecting them. Scrolling down the list of movies a little way, we notice the movie Apollo 13 (1995). Wasn't that one of the movies Kevin Bacon was in?

Page 9: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

9

In the preceding screenshot, we can see both Airport 77 (and we know Joseph Cotton acted in that movie), and Apollo 13 (in which Kevin Bacon acted), in the list of the column of Titles. Rather than searching further, we will now select Apollo 13 by clicking on it in the Title list box to get the overlap of actors. In the following screenshot, we select the Movie Apollo 13 to find the overlapping actor:

We discover that Kathleen Quinlan has worked with both Joseph Cotten and Kevin Bacon. Therefore the connection is: Kevin Bacon | Kathleen Quinlan | Joseph Cotten | author.

There are only three degrees of separation. Not the six degrees of separation as proposed by the theory, Six Degrees of Separation. And as we deduced before, this is only a sample of the possible connections.

This result supports more recent theorization by social psychologist, Stanley Milgram. His study shows that people in the United States seem to be connected by approximately three friendship links, on average.

And now that we know how to play, we should be able to win the game, Six Degrees of Kevin Bacon, with just a little investigation using the QlikView Movie Database.

Page 10: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

10

As of September 2012, Google now has a search that allows you to find the Bacon number for most other actors, so if you need a break from learning about QlikView, you can go to Google.com on the Internet and type in Bacon number and the name of a celebrity. Google will return the Bacon number and the connections to the screen. Finding a celebrity who is more than two degrees of separation from Kevin Bacon may become the new game with the help of Google.

There's more...Collaborating using the QlikView Movie Database might be a good next experiment for learning about QlikView analysis. Although this was an analysis example based on a game, it is a fine example of the options for Social Business Discovery collaborative efforts. You and your friend can work with the very same QlikView Movie Database and choose different paths to discovering links. Perhaps you are interested in seeing how Alfred Hitchcock, the director, connects to both the actors in this example; or to another set of actors. Examine the logic you used to make your choices and explain them to each other.

The QlikView Movie Database is also a great way to get used to using QlikView for investigating data. Starting with the first sheet of the Movie Database, the Intro section, you can read the introduction and click on the Get Started button, which is a link to the next sheet, How QlikView works. Return to the Intro section and right-click on the Get Started button and examine the properties that can be used with sheet objects of the Button type.

The How QlikView works sheet explains the associative colors used. White, green, and gray, with a simple, if not necessarily correct, fruit and color association set of list boxes. Notice the more web-like format of these list boxes. Right-click on the list box and view the properties of these list boxes to find out what formatting choices change the appearance this way.

The Traditional OLAP tab can be skipped since list boxes would not be the way you would normally choose to look at OLAP data anyway.

Hopefully, as you read this recipe, you also played along using the QlikView's Model tab. Now you can further expand your knowledge by changing the properties of the list boxes:

• Add your own chart or graph• Add the year the movies were released to the list box for Titles

• Change the list box title from Title to Movies

• Add icons to the toolbars of the list boxes

Page 11: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

11

The following screenshot shows the changes made the Title list box:

If you need assistance in making any of these changes, refer to the first recipe or to QlikView Help.

Now use Edit Script in the QlikView Movie Database to review the scripts and data fields (although the scripts are not connected and are for example only):

XY_Example:

LOAD * INLINE [

X, Y

Banana, Yellow

Lime, Green

Apple, Green

Apple, Red

];

Notice that the script for the How QlikView works tab is an INLINE Script (see the preceding code) loaded directly from the script. If this was the only script for the QlikView, we could add two lines so that the script looked like the following and correct the fruit color combinations:

XY_Example:

LOAD * INLINE [

X, Y

Banana, Yellow

Lime, Green

Apple, Green

Page 12: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

12

Apple, Red

Banana, Green

Apple, Yellow

];

Because this is not the only script and this database is not licensed to us, QlikView will not allow us to reload because of the missing connections to the other scripts. Also the embedded license will be removed if we save our changes and we will lose all the data.

But you can copy the script, and paste it into Notepad, Wordpad, or another text editor. To do so, follow these steps:

1. Close the QlikView Movie Database and open a QlikView model of your own.

2. Choose Edit Script and paste the copied script into the main script. You can now make the changes to the script, and save them by clicking on OK.

3. Reload to get the Inline data into the memory.4. Now on your main tab add a new sheet object by navigating to Sheet

Object | Multi Box.5. This option allows you to create multiple list boxes at once.6. Choose X and Y as your choices for the list boxes to be created.7. Now you can experiment with formatting your new list boxes and

see that your changes to the script indeed work.

Return to the QlikView Movie Database and using the File menu bring up the table viewer. Here we can see that the XY example we just finished duplicating is a totally independent table with no joins to other tables. Also the Translations table is independent. We can see that most of the remaining tables are joined on a field that is not displayed in the sheet objects, shown as Film ID. We have some supporting tables that join on Length that are used in the final Analysis tab. You can see the table viewer's Source Table View in the following screenshot:

Page 13: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

13

We can switch from the Source Table View to Internal Table View by using the drop-down box near the upper-right corner of the interface.

The Internal Table View shows us that QlikView created an internal synthetic key and table to track the relationship between the LengthRange and IntervalMatch tables. We can now exit the table viewer.

Open the Edit Script interface again so that we can look at the other scripts. Begin by reviewing the example script that supports the QlikView Model tab of the Movie Database.

Here is a segment of the script from the FilmsDatabase script tab:

Films:

LOAD

*,

Rating as RatingSquare,

Rating as RatingStar,

if(Rating = 5, RGB(103, 167, 202),

Page 14: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

14

if(Rating = 4, RGB(140, 191, 218),

if(Rating = 3, RGB(175, 212, 230),

if(Rating = 2, RGB(186, 218, 233),

if(Rating = 1, RGB(232, 241, 246),

RGB(205, 205, 205)))))) as RatingColor

;

Actors:

LOAD FilmID,

Actor

FROM

[..\Database\Films Database.xls]

(biff, embedded labels, table is Actors$);

LOAD FilmID,

Actor

FROM

[..\Database\Films Database.xls]

(biff, embedded labels, table is Actors2$);

Notice in the script segment present in the preceding code, that we are loading the same file for Actors twice, once as Actors$ and once as Actors2$. The script also creates a count of films by loading the value 1 as the field Filmcount. The last parts of the script create the LengthRange table as numbers to compare against; and descriptions of what those numbers represent. The script then loads the actual length of the film as the LengthRange field.

The RGB(103, 167, 202) portion of the script assigns colors to the Ratings based on the rating numbers using Red Green Blue color coding numbers.

Here is the script from the Rating script tab:

BundleRatingImage:

BUNDLE INFO LOAD * INLINE [

RatingStar, Image

5, '..\Images\5-stars.png'

4, '..\Images\4-stars.png'

3, '..\Images\3-stars.png'

2, '..\Images\2-stars.png'

1, '..\Images\1-star.png'

];

Page 15: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

15

BundleSquareRatingImage:

BUNDLE INFO LOAD * INLINE [

RatingSquare, Image

5, '..\Images\square-5-stars.png'

4, '..\Images\square-4-stars.png'

3, '..\Images\square-3-stars.png'

2, '..\Images\square-2-stars.png'

1, '..\Images\square-1-star.png'

];

//Unrated, '..\Images\unrated-stars.png'

This script loads in the images associated with the rows of stars in the Ratings row above the Average Length of Movies Over Time chart on the Analysis tab. This type of display is called a Spark Line. When a particular movie is selected, the tiny box next to the ratings spark line turns white. Unlike the example scripts from the QlikView Movie Database, it is highly recommended to use comments extensively in any scripts that you write from scratch or edit. It is worthwhile to take the extra minute or two adding information that makes your scripts understandable to others and to help you remember what the script is doing. Comments are designated by starting the line with // or bracketing the paragraph with /* */.

Why, when we look at the Analysis tab and select Alfred Hitchcock as the director, we see the number 68 next to his name indicating the number of movies that have been directed by him, yet the list of movies shows eighty-one? Notice the Clear button below the list boxes. This was added to the sheet as a separate sheet object to successfully clear all the sheet objects at once and return the chart for movie length back to its original appearance. What are some of the other actions that this Button sheet object might do? Right-click on the Clear button and choose Properties to investigate.

Examine the other objects on the sheet by right-clicking on it. See that the Rating section is a list box. Notice that long gray button type objects that switch between the bar/line graph and the list view are sitting inside a Container object. Container objects are used to group other sheet objects and their functionality within a sheet.

Traditional Business Intelligence applications are report-centric with dashboards designed for the executive management level user. They force individual users to make decisions based on static preconfigured data. Often the data marts or warehouses have taken years to build and do not include data from outside the firm.

Page 16: Ins v w-to - static.packt-cdn.com · Ins v w-to 3 For this game, we are going to use the QlikView Model sheet, the fourth tab from the left. Here we can start with the actors. It

Instant QlikView App Development How-to

16

QlikView's Social Business Discovery interface is different because it supports all business users from all groups and departments, encouraging them to collaborate on what data to use, different ways to analyze that data, and what decisions they reach consensus on based on the their analysis. The applications are interactive, enabling business users to explore relevant data without limits. The interface can be setup to use collaborative "co-browsing" sessions to investigate current and constantly updating data. The interface also allows the users to create bookmarks and notes to let users share insight for discussion and debate over time. Let us see how to create a bookmark:

1. Open the Bookmark option from the Bookmarks menu item in the menu bar. From this option you can add, manage, and delete bookmarks.

2. Add a Bookmark. Give it a different name than the date and default number.

3. Review the different checkbox options: Share the Bookmark, Include the Selections, and Include the Layout State.

4. Click on OK to save the bookmark, and then open the Bookmarks menu item to see your bookmark listed.

The QlikView Movie Database licensing will not let you save the changes when you close the database, so your bookmark will not be available next time you open the database. In a server environment with enterprise licensing, these notes and bookmarks are available to other users and the bookmark recalls the particular selections that were in use when the bookmark was added.