TITLE OF PRESENTATION PRESENTER
Web Intelligence Advanced #2 Join us as we cover techniques that will help you to successfully build more advanced reports in This Web Intelligence. We will present these concepts: merging dimensions, inner vs. outer joins, and variables & formulas (object types and conversion, basic functions, if-then-else, sum-where, and forall- foreach). Prior experience with Web Intelligence is recommended.
Join Types Structured Query Language provides two main methods for joining data from two separate tables Inner Join – includes only those records that have a matching key in both tables Outer Join – includes all records from the primary table, but only those records that have a matching key in the second table. Left or Right Outer indicates which table is considered to be primary
Simple Example EMPLOYEE_NO FIRST_NAME LAST_NAME 11111 Eder Roux 22222 Maldwyn Bootsma 33333 Ariston Leone EMPLOYEE_NO CONTRACT_YEAR JOB_CODE 11111 2015 TEACH 2016 22222 COACH
Result of Inner Join Only records with a matching key (EMPLOYEE_NO) in both tables are returned EMPLOYEE_ NO FIRST_NAME LAST_NAME CONTRACT_ YEAR JOB_CODE 11111 Eder Roux 2015 TEACH 2016 22222 Maldwyn Bootsma COACH
Result of Outer Join All records from EMPLOYEE_MASTER are included with EMPLOYEE_JOBS that have a matching key EMPLOYEE_ NO FIRST_NAME LAST_NAME CONTRACT_ YEAR JOB_CODE 11111 Eder Roux 2015 TEACH 2016 22222 Maldwyn Bootsma COACH 33333 Ariston Leone
Filtering Note that filtering can also have an unintended effect WHERE CONTRACT_YEAR = ‘2016’ EMPLOYEE_ NO FIRST_NAME LAST_NAME CONTRACT_ YEAR JOB_CODE 11111 Eder Roux 2016 TEACH 22222 Maldwyn Bootsma COACH
Query in Web Intelligence How do we know what type of join will be used? Check SQL using the View Script button
Checking the SQL Script SELECT HRS.EMPLOYEE_MASTER.EMPLOYEE_NO, HRS.EMPLOYEE_MASTER.FIRST_NAME, HRS.EMPLOYEE_MASTER.LAST_NAME, HRS.EMPLOYEE_JOBS.CONTRACT_YEAR, HRS.EMPLOYEE_JOBS.JOB_CODE FROM HRS.EMPLOYEE_MASTER, HRS.EMPLOYEE_JOBS WHERE ( HRS.EMPLOYEE_MASTER.EMPLOYEE_NO=HRS.EMPLOYEE_JOBS.EMPLOYEE_NO(+) ) AND ( ( hrs.hesec03a ('EMPLOYEE_MASTER', ( HRS.EMPLOYEE_MASTER.EMPLOYEE_NO ), upper(@Variable('BOUSER'))) = 'Y' ) ( amsec01b_(upper(@Variable('BOUSER')), 'HMEMP01AFMX') = 'Y' ) ( amsec01b_(upper(@Variable('BOUSER')), 'HEJOB01AFMX') = 'Y' ) HRS.EMPLOYEE_MASTER.EMPLOYEE_NO=HRS.EMPLOYEE_JOBS.EMPLOYEE_NO(+) (+) indicates an outer join and is placed at the end of the second (non-primary) table
Merging Dimensions How do we build this query? Show all employees Only include Jobs with Contract Year of 2015 Solution also works for inner joins
Example with Lab Data
Setting up a Query Limiting Contract Year to 2015 Employees will get lost – no job record for 2015 Solution: Build 2 Queries
Create First Query Click Add Query to add a query for Jobs Right click and choose to Rename this query
Add Jobs Query
Two Queries – Two Tables Two separate tables are created Notice Employee No from each query (Employees) (Jobs) And delete this second table Highlight each Employee No. Then right click and choose to Merge them.
Right click Variables and choose Combining the Data We cannot use dimensions from opposite queries Dragging Job Code or Contract Year gives an “incompatible” message Instead, we will convert them to details Right click Variables and choose New Variable
Job Code Name: Job Code – Detail Qualification: Detail Associated dimension: Employee No (Merged) Formula: =[Job Code]
Contract Year Name: Contract Year – Detail Qualification: Detail Associated dimension: Employee No (Merged) Formula: =[Contract Year]
Combined Table Tables always “group by” dimensions Details are considered an extension of a dimension Employee No is merged so its extensions can exist in the same table
Watch for WebI Merging For You Consider the following query:
View Script to Reveal 3 Queries Common dimensions are merged
Object Types Dimension Detail Measure A category of information to be measured Always grouped so that distinct values are shown in tables Detail An attribute of a dimension (or merged dimension) Must be one-to-one with the dimension Measure A measured value that can be summarized by one or more dimensions Automatically aggregated by dimensions included in a table Sometimes we will want to convert dimensions to measures using variables.
Formulas Adjust, expand, and customize data Example: Add a calculated balance column Create a new column to the right of Amount – YTD with Default Open the Formula Editor Formula for selected cell is displayed in the Formula Bar Formula Editor button will bring up advanced screen
The formula can be typed or built from the items below. To insert, items can be double clicked or dragged into the Formula box. Formula text is the same as on Formula Bar Simple math can be used for our balance Descriptive help provides information about how to use functions Objects from queries or variables Library of functions to be used to create our desired result Operators to be used for comparison
New Balance Column
Formula Notes Cell formula can be shared by placing it in a variable Formula always starts with equals = Objects & variables use [square brackets] Literal strings use “quotation marks” Concatenate strings with plus + Function Parameters are separated by semi colons ;
Example Functions in Expressions =Sum([Adjusted Budget – YTD with Default]) =Left([Fund];1) =[First Name] + “ “ + [Last Name] =Max(ToNumber([Employee No)]) =ReportName() =“Page “ + Page() + “ of " + NumberOfPages()
If… Then… Else… If statements do not use parentheses Example: =If [Balance Percentage] > .20 Then "Time to spend" ElseIf [Balance Percentage] > 0 Then "Slow down" Else "Stop spending!“
Sum Where (out there) Add Where() function to an aggregate function to limit included values Example: =Sum ([Adjusted Budget - YTD with Default]) Where ([Location] <> "33 – Administration")
In, Forall, and Foreach Used to calculate values outside of context dictated by cell position within report, group, or table ForAll (dimensions) Removes dimensions from the calculation context Foreach (dimensions) Adds dimensions to the calculation context In (dimensions) Specifies the specific dimensions to use in the calculation context
ForAll Example Total Fund budget for all locations: =Sum([Adjusted Budget - YTD with Default]) ForAll ([Location]) Could also show grand total with: =Sum([Adjusted Budget - YTD with Default]) ForAll ([Fund];[Location])
ForceMerge Function Back to the example with separate Employees and Jobs queries Add Contract Salary to Jobs query Shows ok in table because Employee No is merged
Removing Employee No If we don’t want to show Employee No, we have a problem The table doesn’t see the link to Contract Salary
Use ForceMerge Function Force the table to follow merged dimension relationship =ForceMerge([Contract Salary])
Additional Training If you are interested in other alio WebEx group training sessions, you can view a list of sessions currently available at, http://www.myalio.com/web-training/ If you prefer one-on-one training, please contact your alio support provider directly for cost and scheduling information. If you have any questions or concerns, please contact alio support at 1-800-914-9879 or by direct e-mail to wccc@hammer.net.