Advanced Set Analysis - MLT Vacations

Embed Size (px)

Citation preview

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    1/31

    Advanced Set AnalysisMLT Vacations

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    2/31

    Problem

    Our goal here is to analyze specific flight patterns and compare thecurrent numbers to the previous year.

    We will define our criteria using QlikView selections. Selections work wellin this situation, because they are easy to use within Set Analysis andallow our users the flexibilit to modif the criteria on-the-fl .

    Due to the structure of our data, simply making the selections will not beenough to get us the answers we are looking for. Our datasetcontains multiple records for each booking, one record for each

    activity the customer will do during their trip. Bookings can alsoinclude multiple customers, so well have to verify that each booking

    and customer we include matches the criteria.

    Since the specific flight pattern we are looking for will only match onerecord, well need to include any customer where at least one recordmatches our selected criteria.

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    3/31

    Data

    Our data is structured as follows. We want to include any customer thattakes a flight from MSP to CUN. We must be sure to include allrevenue associated with that customer, not just the revenueassociated with that specific flight.

    oo ng us omer ype r g es en s r ev

    12345 A A MSP CUN 1 100

    12345 A H 0 0

    12345 B A MSP ATL 1 75

    12345 B A ATL CUN 0 75

    12345 B H 0 0

    67890 A A MSP CUN 1 10067890 B A MSP CUN 1 100

    67890 A H 0 0

    67890 B H 0 0

    24680 A A FAR MSP 1 75

    24680 A A MSP CUN 0 100

    24680 A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    4/31

    Now lets see what happens when we make some selections. We are lookingat flights from MSP to CUN.

    Booking Customer Type Orig Dest Clients Air Rev

    12345 A A MSP CUN 1 100

    12345 A H 0 0

    12345 B A MSP ATL 1 75

    12345 B A ATL CUN 0 75

    12345 B H 0 0

    67890 A A MSP CUN 1 100

    67890 B A MSP CUN 1 100

    67890 A H 0 0

    67890 B H 0 0

    24680 A A FAR MSP 1 75

    24680 A A MSP CUN 0 100

    24680 A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    5/31

    Selecting our Origin includes any flight originating in MSP

    Booking Customer Type Orig Dest Clients Air Rev

    12345 A A MSP CUN 1 100

    12345 A H 0 0

    12345 B A MSP ATL 1 75

    12345 B A ATL CUN 0 75

    12345 B H 0 0

    67890 A A MSP CUN 1 100

    67890 B A MSP CUN 1 100

    67890 A H 0 0

    67890 B H 0 0

    24680 A A FAR MSP 1 75

    24680 A A MSP CUN 0 100

    24680 A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    6/31

    We only want customers taking a flight from MSP to CUN, so this firstselection included a record we did not want.

    Booking Customer Type Orig Dest Clients Air Rev

    12345 A A MSP CUN 1 100

    12345 A H 0 0

    12345 B A MSP ATL 1 75

    12345 B A ATL CUN 0 75

    12345 B H 0 0

    67890 A A MSP CUN 1 100

    67890 B A MSP CUN 1 100

    67890 A H 0 0

    67890 B H 0 0

    24680 A A FAR MSP 1 75

    24680 A A MSP CUN 0 100

    24680 A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    7/31

    Making our selection on the Destination eliminates the unwanted records.

    Selecting both Origin & Destination requires that both values are present in asingle record, which is what we want for this exercise.

    Booking Customer Type Orig Dest Clients Air Rev

    12345 A A MSP CUN 1 100

    12345 A H 0 0

    12345 B A MSP ATL 1 7512345 B A ATL CUN 0 75

    12345 B H 0 0

    67890 A A MSP CUN 1 100

    67890 B A MSP CUN 1 100

    67890 A H 0 0

    67890 B H 0 0

    24680 A A FAR MSP 1 75

    24680 A A MSP CUN 0 100

    24680 A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    8/31

    As you can see in the circled cells, including only the selected records willresult in us not counting all passengers and missing out on some revenue.

    Booking Customer Type Orig Dest Clients Air Rev

    12345 A A MSP CUN 1 100

    12345 A H 0 0

    12345 B A MSP ATL 1 7512345 B A ATL CUN 0 75

    12345 B H 0 0

    67890 A A MSP CUN 1 100

    67890 B A MSP CUN 1 100

    67890 A H 0 0

    67890 B H 0 0

    24680 A A FAR MSP 1 75

    24680 A A MSP CUN 0 100

    24680 A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    9/31

    Well use Set Analysis to select every record for any customer who meets theselected criteria.

    Booking Customer Type Orig Dest Clients Air Rev

    12345 A A MSP CUN 1 100

    12345 A H 0 0

    12345 B A MSP ATL 1 7512345 B A ATL CUN 0 75

    12345 B H 0 0

    67890 A A MSP CUN 1 100

    67890 B A MSP CUN 1 100

    67890 A H 0 0

    67890 B H 0 0

    24680 A A FAR MSP 1 75

    24680 A A MSP CUN 0 100

    24680 A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    10/31

    The first thing we will do is build our expression in an intermediate tableusing the natural dimensions.

    Building your Expression in an intermediate table will be:

    Implementation

    Easier to troubleshoot

    More accurate

    Used directly in our final expression

    In this example, our natural dimensions will be Booking and CustomerID. Since this level of analysis is common for us, our dataset containsone field that is a concatenation of both fields.

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    11/31

    Set Analysis structure and terms

    Here is the basic syntax for a Set Analysis expression and some terms Iwill use throughout the presentation.

    Sum({} FACT)

    Set Expression: {}

    Set Modifier:

    Element Set: {'VALUE'}

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    12/31

    Bk Cust Bk T e Le Ori Le Dest Bk Clients AirRev

    Building Our Revenue Expression

    We will start with a basic Sum function:

    Sum(AirRev)

    12345A A MSP CUN 1 100

    12345A H 0 0

    12345B A MSP ATL 1 75

    12345B A ATL CUN 0 75

    12345B H 0 0

    67890A A MSP CUN 1 100

    67890B A MSP CUN 1 100

    67890A H 0 0

    67890B H 0 0

    24680A A FAR MSP 1 75

    24680A A MSP CUN 0 100

    24680A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    13/31

    Bk Cust Bk T e Le Ori Le Dest Bk Clients AirRev

    Building Our Revenue Expression

    Using Set Analysis and the 1 modifier, we will ignore all selections:

    Sum({1} AirRev)

    12345A A MSP CUN 1 100

    12345A H 0 0

    12345B A MSP ATL 1 75

    12345B A ATL CUN 0 75

    12345B H 0 0

    67890A A MSP CUN 1 100

    67890B A MSP CUN 1 100

    67890A H 0 0

    67890B H 0 0

    24680A A FAR MSP 1 75

    24680A A MSP CUN 0 100

    24680A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    14/31

    The P() Function [and E()]

    We will bring our selections back in to play by utilizing the P() function

    Set Modifiers with Implicit Value Definitions

    n y ava a e n et na ys s as ement ets

    Represents the Element Set of Possible values and Excluded Valuesrespectively

    Can include a Set Expression

    Much faster than alternative methods, such as Concat

    Format:

    {}

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    15/31

    Bk Cust Bk T e Le Ori Le Dest Bk Clients AirRev

    Building Our Revenue Expression

    Using P() we will select all possible BkgCust values

    Sum({1} AirRev)

    12345A A MSP CUN 1 100

    12345A H 0 0

    12345B A MSP ATL 1 75

    12345B A ATL CUN 0 75

    12345B H 0 0

    67890A A MSP CUN 1 100

    67890B A MSP CUN 1 100

    67890A H 0 067890B H 0 0

    24680A A FAR MSP 1 75

    24680A A MSP CUN 0 100

    24680A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    16/31

    Bk Cust Bk T e Le Ori Le Dest Bk Clients AirRev

    Building Our Revenue Expression

    Using P() we will select all possible BkgCust values

    Sum({1} AirRev)

    12345A A MSP CUN 1 100

    12345A H 0 0

    12345B A MSP ATL 1 75

    12345B A ATL CUN 0 75

    12345B H 0 0

    67890A A MSP CUN 1 100

    67890B A MSP CUN 1 100

    67890A H 0 067890B H 0 0

    24680A A FAR MSP 1 75

    24680A A MSP CUN 0 100

    24680A H 0 0

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    17/31

    Variables to simplify Set Analysis expressions

    Variables can be used in place of expressions saving you fromrepeatedly typing the same expression which can lead to errors

    Sum({1} AirRev)

    Set a variable to represent your Set Expression

    vSA= {1}

    We can then simplify our expression using the variable

    Sum($(vSA) AirRev)

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    18/31

    Adding a Previous Year Expression

    We add a Set Expression to the P() function to define the date span

    Sum({1} AirRev)

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    19/31

    Adding a Previous Year Expression

    We add a Set Expression to the P() function to define the date span

    Sum({1} AirRev)

    Define the Element Set as a range

    Sum({1} AirRev)

    It is a good idea to use valid, pre-defined values when first constructing

    the expression

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    20/31

    Defining the Previous Year Span

    Our current year span will be defined by a selection, we will use thisselection to define the previous year span

    Start with the smallest, selected date

    Min(DeptDate)

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    21/31

    Defining the Previous Year Span

    Our current year span will be defined by a selection, we will use thisselection to define the previous year span

    Start with the smallest, selected date

    Min(DeptDate)

    Then modify it for the previous year

    AddYears(Min(DeptDate),-1)

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    22/31

    Defining the Previous Year Span

    Our current year span will be defined by a selection, we will use thisselection to define the previous year span

    Start with the smallest, selected date

    Min(DeptDate)

    Then modify it for the previous year

    AddYears(Min(DeptDate),-1)

    We will use similar logic for the largest valueAddYears(Max(DeptDate),-1)

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    23/31

    Adding the Functions Using Dollar Sign Expansions

    We must use Dollar Sign Expansions for our value functions

    $(=AddYears(Min(DeptDate),-1))

    $(=AddYears(Min(DeptDate),-1))

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    24/31

    Adding the Functions Using Dollar Sign Expansions

    We must use Dollar Sign Expansions for our value functions

    $(=AddYears(Min(DeptDate),-1))

    $(=AddYears(Min(DeptDate),-1))

    If you think back to our expression with pre-defined values, wellkeep the Element Set the same, but replace the dates with ourselection-based functions inside Dollar Sign Expansions

    {>= 7/1/2010

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    25/31

    Adding the Functions Using Dollar Sign Expansions

    We must use Dollar Sign Expansions for our value functions

    $(=AddYears(Min(DeptDate),-1))

    $(=AddYears(Min(DeptDate),-1))

    If you think back to our expression with pre-defined values, wellkeep the Element Set the same, but replace the dates with ourselection-based functions inside Dollar Sign Expansions

    {>=$(=AddYears(Min(DeptDate),-1))

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    26/31

    Tip: Dollar Sign Expansions in Set Expressions

    When building Set Expressions with Dollar Sign Expansions, put yourexpression into a Straight Table, but dont give the expression a label

    When the chart is rendered, the label will be your Set Expression withthe Dollar Sign Expansion evaluated

    Sum({=$(=AddYears(Min(DeptDate),-1))

    }

    AirRev)

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    27/31

    Final Expressions

    We now have working expressions for our selected date span and for theprevious year. These expressions can be used in tables or charts.Since they are dynamic based on a selection, they can be modifiedby the user on-the-fly

    Sum({1} AirRev)

    Sum({1

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    28/31

    Final Expressions

    We now have working expressions for our selected date span and for theprevious year. These expressions can be used in tables or charts.Since they are dynamic based on a selection, they can be modifiedby the user on-the-fly

    Sum($(vSA) AirRev)

    Sum($(vSA_LY) AirRev)

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    29/31

    Charting our Expressions

    And here are our expressions in action

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    30/31

    Set Analysis Summary

    Here are some things to remember as you build your own expressions

    Simplify the problem by using an intermediate expression in atable with natural dimensions

    When working with dollar sign expansions:

    First hardcode a returnable value to verify that your Set

    Expression is working Create a chart and enter your expression without a label to

    determine what the dollar sign expansion is returning

  • 8/7/2019 Advanced Set Analysis - MLT Vacations

    31/31

    [email protected]