Bow320 en Col91 Fv Part Ltr

158
5/19/2018 Bow320enCol91FvPartLtr-slidepdf.com http://slidepdf.com/reader/full/bow320-en-col91-fv-part-ltr-56194866b6362 1/158 BusinessObjects Web Intelligence XI 3.0/3.1: Advanced Report Design Learner’s Guide BOW320

description

BusinessObjects Web Intelligence XI3.0/3.1: Advanced Report Design, BOW 320 PDF Manual

Transcript of Bow320 en Col91 Fv Part Ltr

  • BusinessObjects Web Intelligence XI3.0/3.1: Advanced Report Design

    Learners GuideBOW320

  • Copyright 2009 SAP BusinessObjects. All rights reserved. SAPBusinessObjects owns the followingUnited States patents,whichmay cover products that are offered and licensed by SAPBusinessObjects and/or affliated companies: 5,295,243; 5,339,390;5,555,403; 5,590,250; 5,619,632; 5,632,009; 5,857,205; 5,880,742;5,883,635; 6,085,202; 6,108,698; 6,247,008; 6,289,352; 6,300,957;6,377,259; 6,490,593; 6,578,027; 6,581,068; 6,628,312; 6,654,761;6,768,986; 6,772,409; 6,831,668; 6,882,998; 6,892,189; 6,901,555;7,089,238; 7,107,266; 7,139,766; 7,178,099; 7,181,435; 7,181,440;7,194,465; 7,222,130; 7,299,419; 7,320,122 and 7,356,779. SAPBusinessObjects and its logos, BusinessObjects, Crystal Reports,Rapid Mart, Data Insight, Desktop Intelligence, RapidMarts, Watchlist Security, Web Intelligence, and Xcelsius

    are trademarks or registered trademarks of Business Objects,an SAP company and/or affiliated companies in the UnitedStates and/or other countries. SAP is a registered trademarkof SAPAG inGermany and/or other countries. All other namesmentioned hereinmay be trademarks of their respective owners.

  • C O N T E N T S

    About this CourseCourse Introduction.....................................................................................................xiCourse Description......................................................................................................xiiCourse Audience.........................................................................................................xiiPrerequisites.................................................................................................................xiiAdditional Education..................................................................................................xiiLevel, delivery and duration.....................................................................................xiiApplicable certifications and designations..............................................................xiiCourse success factors.................................................................................................xiiCourse setup...............................................................................................................xiiiCourse materials.........................................................................................................xiiiLearning process ........................................................................................................xiii

    Lesson 1ReviewingWeb IntelligenceCoreReport DesignLesson introduction.......................................................................................................1Reviewing core report design concepts......................................................................2

    Review: Web Intelligence core report design.....................................................2Lesson summary............................................................................................................3

    Lesson 2Working with Advanced Query TechniquesLesson introduction.......................................................................................................5Using combined queries...............................................................................................6

    About combined query functions........................................................................6Understanding when to use a combined query.................................................8Advantages of using combined queries..............................................................9Comparing query filters and combined queries................................................9Using the combined query technique...............................................................10Important facts about combined queries..........................................................11Activity: Combined queries................................................................................12Activity: Combined queries - Optional.............................................................13

    Using subqueries..........................................................................................................16Understanding subqueries..................................................................................16Creating a subquery.............................................................................................16Activity: Using subqueries..................................................................................18

    iiiTable of ContentsLearners Guide

  • Creating a query based on another query ...............................................................20Duplicating queries..............................................................................................20

    Changing data sources................................................................................................22About changing data sources.............................................................................22Activity: Changing the data source...................................................................25

    Quiz: Advanced Query Techniques..........................................................................28Lesson summary..........................................................................................................29

    Lesson 3Working with Calculation ContextsLesson introduction.....................................................................................................31Understanding calculation contexts .........................................................................32

    Dynamic calculations...........................................................................................32Redefining calculation contexts.................................................................................35

    Input and output contexts...................................................................................35Forcing the input calculation context................................................................36About the extended syntax operators and keywords ....................................39Forcing the output calculation context..............................................................40More about the extended syntax keywords.....................................................43Input vs. output calculation contexts................................................................43Using the In context operator with Where.......................................................44Important facts about calculation contexts.......................................................46Activity: Calculation contexts.............................................................................46Activity: Calculation contexts - Optional..........................................................47

    Quiz: Calculation Contexts.........................................................................................49Lesson summary..........................................................................................................50

    Lesson 4Creating Formulas with Character and DateString FunctionsLesson introduction.....................................................................................................51Using character strings................................................................................................52

    About character-string functions.......................................................................52Using functions in formulas and variables.......................................................52

    Using the Right() function .........................................................................................53How to extract characters using the Right() function.....................................53

    Using the Replace() function......................................................................................56Replacing a string.................................................................................................56

    Using the SubStr() function .......................................................................................58How to extract characters using the SubStr() function...................................58

    Using the Pos() function.............................................................................................60How to use the Pos() function............................................................................60

    Concatenating different character strings................................................................62

    Web Intelligence Advanced Report DesignLearners Guideiv

  • How to concatenate a string with a date...........................................................62Formatting a date that is concatenated with a string......................................62

    Using date functions ...................................................................................................65Converting a string to a date value ..................................................................65Using date calculations........................................................................................66Activity: Character and date string functions .................................................67Activity: Character and date string functions - 2.............................................68Converting a string to a date value ..................................................................69

    Quiz: Character and Date String Functions ............................................................71Lesson summary..........................................................................................................72

    Lesson 5Using If LogicLesson introduction.....................................................................................................73Using If() to group data..............................................................................................74

    Grouping values with the If() function to show higher levels ofdetail.......................................................................................................................74Grouping values with the If() function to show categories...........................75Activity: Grouping data......................................................................................77Activity: Grouping data - Optional...................................................................78Activity: Grouping data - Optional 2................................................................80

    Using the If() function to modify calculation behavior..........................................82Modifying the way calculations behave...........................................................82Syntax of the If() function ...................................................................................84Activity: Modifying the calculation behavior..................................................84

    Quiz: Using If Logic.....................................................................................................86Lesson summary..........................................................................................................87

    Lesson 6Working with Additional Reporting TechniquesLesson introduction.....................................................................................................89Using data tracking.....................................................................................................90

    Understanding data tracking..............................................................................90Using formula language to track data changes...............................................90Security for data tracking....................................................................................91Activity: Calculating on changed data..............................................................91

    Using additional report functions.............................................................................94Determining matches in strings.........................................................................94Overriding a report filter or ranking.................................................................94Displaying a running sum..................................................................................96Displaying drill filters in the report...................................................................98Understanding additional functions.................................................................99Activity: Displaying data restricted by a filter or ranking...........................100

    Quiz: Additional Reporting Techniques................................................................104

    vTable of ContentsLearners Guide

  • Lesson summary........................................................................................................105

    Lesson 7Creating HyperlinksLesson introduction...................................................................................................107Working with hyperlinks in Web Intelligence documents..................................108

    About hyperlinks in Web Intelligence............................................................108Creating hyperlinks in the Web Intelligence Interactive panel...........................109

    About hyperlinks in the Interactive panel......................................................109Creating hyperlinks in Web Intelligence Rich Client and the Java ReportPanel............................................................................................................................114

    About hyperlinks to a URL ..............................................................................114Activity: Creating hyperlinks in the Interactive panel.................................116

    Quiz: Creating Hyperlinks.......................................................................................118Lesson summary........................................................................................................119

    Appendix AOptional End of Course ChallengeActivity: Using advanced querying and reporting techniques...........................121

    Appendix BCreating Hyperlinks with the OpenDocumentCommandUsing OpenDocument to create a hyperlink to documents ...............................123OpenDocument URL command syntax ................................................................123More about using the OpenDocument URL .........................................................125Finding more information .......................................................................................126

    Appendix CDimensions and DetailsUnderstanding dimensions and details .................................................................127Understanding the impact of changing the object qualification.........................128Review: Dimensions and details .............................................................................128

    Answer KeyReview: Web Intelligence core report design........................................................131Quiz: Advanced Query Techniques........................................................................134Quiz: Calculation Contexts.......................................................................................135Quiz: Character and Date String Functions ..........................................................136

    Web Intelligence Advanced Report DesignLearners Guidevi

  • Quiz: Using If Logic...................................................................................................137Quiz: Additional Reporting Techniques................................................................138Quiz: Creating Hyperlinks.......................................................................................139Review: Dimensions and details .............................................................................140

    viiTable of ContentsLearners Guide

  • Web Intelligence Advanced Report DesignLearners Guideviii

  • A G E N D AWeb Intelligence Advanced Report Design

    Introductions, Course Overview...........................................30 minutes

    Lesson 1Reviewing Web Intelligence Core Report Design...........30 minutes Reviewing core report design concepts

    Lesson 2Working with Advanced Query Techniques...............................1 hour Using combined queries Using subqueries Creating a query based on another query Changing data sources

    Lesson 3Working with Calculation Contexts........................................1.5 hours Understanding calculation contexts Redefining calculation contexts

    Lesson 4Creating Formulas with Character and Date StringFunctions.........................................................................................1.5 hours Using character strings Using the Right() function Using the Replace() function Using the SubStr() function Using the Pos() function Concatenating different character strings Using date functions

    Lesson 5Using If Logic.......................................................................................1 hour Using If() to group data Using the If() function to modify calculation behavior

    ixAgendaLearners Guide

  • Lesson 6Working with Additional Reporting Techniques.......................1 hour Using data tracking Using additional report functions

    Lesson 7Creating Hyperlinks..................................................................45 minutes Working with hyperlinks in Web Intelligence documents Creating hyperlinks in the Web Intelligence Interactive panel Creating hyperlinks in Web Intelligence Rich Client and the Java ReportPanel

    Web Intelligence Advanced Report DesignLearners Guidex

  • About this Course

    Course Introduction

    This section explains the conventions used in the course and in this training guide.

    xiAbout this CourseLearners Guide

  • Course Description

    BusinessObjects Web Intelligence is a query, reporting and analysis tool that allows you toaccess the data in your corporate databases directly from within BusinessObjects Enterprise

    InfoView and to present and analyze this information in a Web Intelligence document.

    This one-day instructor-led classroom course is designed to give you the comprehensive skillsneeded to apply alternative query and reporting techniques when creating complex WebIntelligence documents. After completing this course, you will be able to create combinedqueries and use sub-queries. You will also be able to use character and date string functions,create variables using "If" logic, and redefine calculation contexts.

    The course also provides an optional appendix describing how to link Web Intelligencedocuments using the OpenDocument URL command.

    Course Audience

    The target audience for this course is report designers who are experienced Web Intelligenceusers and who need to create complex Web Intelligence documents.

    Prerequisites

    Learners should have attended the following courses:

    BusinessObjects Web Intelligence XI 3.0/3.1: Report Design

    To be successful, learners who attend this course should have the following experience:

    Experience designing Web Intelligence reports

    Additional Education

    Not applicable for this offering.

    Level, delivery and duration

    This advanced-level instructor-led offering is a one-day course.

    Applicable certifications and designations

    This is an intermediate course for the Business Objects Certified Professional - BusinessObjectsWeb Intelligence XI 3.0/3.1 certification path.

    Course success factors

    Your learning experience will be enhanced by:

    Web Intelligence Advanced Report DesignLearners Guidexii

  • Activities that build on the life experiences of the learner Discussion that connects the training to real working environments Learners and instructor working as a team Active participation by all learners

    Course setup

    Refer to the setup guide for details on hardware, software, and course-specific requirements.

    Course materials

    The materials included with the course materials are:

    Name card Learners Guide

    The Learners Guide contains an agenda, learner materials, and practice activities.

    The Learners Guide is designed to assist students who attend the classroom-based courseand outlines what learners can expect to achieve by participating in this course.

    Evaluation form

    At the conclusion of this course, you will receive an electronic feedback form as part of ourevaluation process. Provide feedback on the course content, instructor, and facility. Yourcomments will assist us to improve future courses.

    Additional resources include:

    Sample files

    The sample files can include required files for the course activities and/or supplementalcontent to the training guide.

    OnlineHelp

    Retrieve information and find answers to questions using the onlineHelp and/or usersguide that are included with the product.

    Learning process

    Learning is an interactive process between the learners and the instructor. By facilitating acooperative environment, the instructor guides the learners through the learning framework.

    Introduction

    Why am I here? Whats in it for me?

    The learners will be clear about what they are getting out of each lesson.

    xiiiAbout this CourseLearners Guide

  • Objectives

    How do I achieve the outcome?

    The learners will assimilate new concepts and how to apply the ideas presented in the lesson.This step sets the groundwork for practice.

    Practice

    How do I do it?

    The learners will demonstrate their knowledge as well as their hands-on skills through theactivities.

    Review

    How did I do?

    The learners will have an opportunity to review what they have learned during the lesson.Review reinforces why it is important to learn particular concepts or skills.

    Summary

    Where have I been and where am I going?

    The summary acts as a recap of the learning objectives and as a transition to the next section.

    Web Intelligence Advanced Report DesignLearners Guidexiv

  • Lesson 1Reviewing Web Intelligence Core Report Design

    Lesson introduction

    In this lesson youwill review and consolidate your knowledge of keyWeb Intelligence conceptsrequired for advanced report design.

    After completing this lesson, you will be able to:

    Build on your knowledge of the Web Intelligence core reporting concepts reviewed

    1Reviewing Web Intelligence Core Report DesignLearners Guide

  • Reviewing core report design concepts

    After completing this unit, you will be able to:

    Build on your knowledge of Web Intelligence core concepts to become an advanced reportdesigner.

    Review: Web Intelligence core report design

    1. A Web Intelligence document consists of three components. What are they?

    2. A query filter contains three components. What are they?

    3. What object type does not have a list of values?

    4. When you list values in a formula, what must you use to separate the values?

    5. What are the two benefits provided when you apply a break to a table?

    6. What are the differences among a query filter, a report filter, and a block filter?

    7. What is the difference between a section and a break?

    8. What is the difference between an ascending or descending sort and a custom sort?

    9. Why purge the data in your document?

    10.What is the difference between a dimension and a detail?

    11.You have two queries on two different data sources. Query 1 returns 10 rows for Region.Query 2 returns 12 rows forRegion_Area . You synchronize the twodata sources bymergingthe Region and Region_Area objects.

    How many rows appear after the synchronization?

    12.You have a report with the objects Region, Year, and Sales revenue in Query 1, and youhave another report on a different data source with Region,Area, and Sales total in Query2. Which objects do you choose to merge to synchronize the information in one table?

    13.When you synchronize two queries fromdifferent data sources,what rulesmust you respect?

    14.Can you synchronize the data between a Web Intelligence document and an Excelspreadsheet?

    Web Intelligence Advanced Report DesignLearners Guide2

  • Lesson summary

    After completing this lesson, you are now able to:

    Build on your knowledge of the Web Intelligence core reporting concepts reviewed

    3Reviewing Web Intelligence Core Report DesignLearners Guide

  • Web Intelligence Advanced Report DesignLearners Guide4

  • Lesson 2Working with Advanced Query Techniques

    Lesson introduction

    After completing this lesson, you will be able to:

    Use combined queries Use subqueries Create a query based on another query Change data sources

    5Working with Advanced Query TechniquesLearners Guide

  • Using combined queries

    When youdesignWeb Intelligence documents, there are certain instanceswhere youmayneedto build two or more queries to retrieve the results you require in your report.

    As a Web Intelligence user, there are several techniques available that enable you to do this.They are: Data synchronization using merged dimensions

    Data synchronization refers to the process of merging data from multiple sources into asingle block in a document.

    Note: This technique is presented in the BusinessObjects Web Intelligence XI 3.0/3.1: ReportDesign course.

    Subqueries

    The subquery technique enables you to specify the output of a query as the operand value(s)for a query filter of another query.

    Note: The subquery technique is presented later in this lesson.

    Combined queries

    The combined queries technique enables you to create two queries and merge the resultsof both into a single data provider on a selective basis. This can be done by using the Union,Intersection, or Minus functions.

    Note: In this unit, you will see that combining queries in a single data provider is differentfrom synchronizing multiple data providers using merged dimensions.

    This unit describes how to use combined queries.

    After completing this unit, you will be able to:

    Describe the Union, Intersection, and Minus functions used to combine queries Discuss reasons and advantages to using combined queries instead of applying complex

    filters Create a combined query Remove a combined query List important facts to remember when using combined queries

    About combined query functions

    Adding single and complex query filters to a query allows you to restrict the amount ofinformation returned by the query. This standard technique allows you to combine multiplefilters in a single query, and these combinations can be designed to make queries very specificand limiting.

    However, this technique only works with a single query. There may be situations when youwant to combine the results of two queries into a single block.

    Web Intelligence Advanced Report DesignLearners Guide6

  • To accomplish this, you must build a combined query. All combined queries are built in theQuery panel, and can only be built using a single universe. Each query needs to have the samenumber of objects as well as the same data types.

    There are three methods of combining queries:

    Union: combines results which appear in Query 1 OR Query 2.

    You use a union query to combine the data from two objects in a single column in a table.Union queries are especially useful for working with incompatible objects.

    For example, if you built a query with two incompatible objects, Web Intelligence wouldrun separate SQL statements for each object and then return the data in different blocks(tables). A union query forcesWeb Intelligence to return the data from both objects togetherin one column.

    Unions, when used to combine the results of two queries using the same objects, will removeduplicate values, leaving a single instance of the duplicate in the report.

    Note: Union is the default operator for combined queries.

    Intersection: combines results which appear in Query 1 AND Query 2.

    You use an intersection query to obtain data common to two sets of results. Like a unionquery,Web Intelligence considers each select statement separately and combines their resultsin the end.

    7Working with Advanced Query TechniquesLearners Guide

  • Unlike a union query, the intersection query only returns those values that are in bothqueries. In this sense, it works much the same as using the AND operator when creating aregular query with multiple query filters.

    Minus: combine results which include everything in Query 1 except for what is also true inQuery 2.

    You use aminus query to exclude the results of one query from themain query result (Query1). For example, a minus query could be used to find out which customers bought productA but not product B.

    You could not obtain this data with standard query filters since the result sets need to beobtained separately before being combined. Like a union query, the minus query considerseach query separately and combines their results in the end.

    When you build minus queries, you must pay attention to the order of the queries, sincethe results of Query 2 will always be subtracted from the results of Query 1.

    Understanding when to use a combined query

    The following is a typical scenario where you might choose to use a combined query:

    You need to find the dates on which your customers either made reservations or paid theirinvoices. The query requires two incompatible objects: Invoice Date and Reservation Date.While the data that the objects represent is identical (that is, a date is a date), the intent of thedates is incompatible and therefore, the objects are incompatible.

    Since the objects are incompatible, if you include them in a standard query, Web Intelligencereturns two blocks of data and does not synchronize the values in a single block.

    However, by building a combined query using the Union function, with Invoice Date in thefirst query andReservation Date in the other, the data appears in a single column in the block.

    Combining queries is similar but not equivalent to Boolean logical operators that youmay haveusedwhen combining conditions in a single query. The Intersection function is similar in effectto AND; the Union function is similar in effect to OR; the Minus function is similar in effect toNOT.

    However, the column of data retrieved by the combined query displays a header that reflectsthe date object from the first query only. In other words, using the example above, the queryreturns a column entitled Invoice Date, but the column actually contains both invoice dates

    Web Intelligence Advanced Report DesignLearners Guide8

  • and reservation dates. This is important to understand, as it may require you to reformat thecolumn header.

    Advantages of using combined queries

    There are a number of reasonswhy youmaywant to use combined queries instead of applyingmultiple query filters against a single query:

    To make the construction of the query easier

    When it is not possible to set the required query filters using Boolean logic

    The downside of using the combined query technique is that because you are actually creatingmultiple queries, processing against the database may take longer.

    Note: A decision on whether to use query filters or a combined query to retrieve the data you needoften depends on how the data is structured in your database.

    Comparing query filters and combined queries

    Suppose that you have been asked by theMarketingManager of the eFashion group to producea report listing all products that have not had a special promotion across all stores.

    The resulting report should list 203 products that have not had a special promotion.

    Note: The table in this image has been truncated.

    To produce this report, you need to resolve issues concerning data integrity.

    9Working with Advanced Query TechniquesLearners Guide

  • If you create two queries, one to show the total list of product SKU numbers and SKUdescriptions, the other to show the list of SKU numbers, SKU descriptions, and products thathave had a promotion (Promotion y/n), and then apply a count on the SKU number columnfor each query, you will see that while the first query produces a list of 211 records, the secondproduces a list of only 8.

    This is because the eFashion database only has information on product promotions where apromotion has actually occurred.

    In this case, of the 211 records available, there are only 8 records where an entry identifies thata promotion has taken place. If you apply a query filter to display only those products wherethe Promotion y/n value is not equal to Yes, you get a message stating that there is no data toreturn. You get the same message if you apply a query filter to display only those productswhere the Promotion y/n value is null.

    Due to a relational database limitation, when products are listed with a Promotion column,only products that have a Promotion y/n value will show up in the report. This is a commondata integrity issue. You need to use a combined query to generate the results you require.

    Using the combined query technique

    The combined query technique combines the results of one query with the results of anotherquery into a single query, or data provider. Themanner inwhich the data is combined dependson the function you choose: Union, Minus, or Intersection .

    In the previous scenario, you could not generate a table listing only the products for whichthere were no promotions, because the Promotion y/n object only contains data about theproducts for which there were promotions. However, you can generate the table you need bycreating a combined query using the SKUNumber and SKU desc objects in Combined Query1, and adding the following query filter to Combined Query 2.

    The first query produces a list of all products, and the second query produces a list of onlythose products for which there has been a promotion. By using the Minus function to combinethe two queries, you can generate a table that subtracts the 8 records generated by CombinedQuery 2 from the 211 generated by Combined Query 1, resulting in a table listing the 203products for which there has been no promotion.

    To build a combined query

    1. Create an initial query in theQuery panel.

    Web Intelligence Advanced Report DesignLearners Guide10

  • 2. Click Combined Query on the toolbar.

    Web Intelligence adds a copy of the initial query to the data provider. The second queryhas the following characteristics:

    It contains the same objects as the original query. It does not contain the filters defined on the original query. It is combined with the original query in a Union relationship.

    3. To switch to a query, click Combined Query n.

    The individual queries in the combined queries are named Combined Query n.

    4. To delete a query, right-click theCombinedQuery n youwant to delete, then selectRemoveon the menu.

    5. To change the combination type, double-click the operator. The operator moves throughthe sequence Union, Intersection,Minus.

    6. Build each query within the combined query as you build any normal Web Intelligencequery.

    7. Click Run Query.

    Important facts about combined queries

    Below are some important facts to keep in mind when you use combined queries: Queries that you combine must be built using the same universe. Queries that you combine must contain the same number of objects to run successfully. When you build a combined query to return data from more than one object in a column,

    for example, using the Union operator, you must use objects of the same type (character,date or number).

    11Working with Advanced Query TechniquesLearners Guide

  • Only the objects placed in the first query are displayed in the block after the query is run.Any object used in a combined query does not display in its own column, but instead, thevalues are returned in the same column as the object from the first query.

    Web Intelligence's default behavior when combining queries is to perform a Union (not aUnionAll) and to return all values less the duplicates. You need to define a custom formulaor variable for Web Intelligence to perform a UnionAll.

    Retrieving duplicate or unique rows

    In a database, the same data may be repeated over many rows. By default, Web Intelligenceautomatically returns all rows, even if they are repeated. This default behavior may cause aninaccurate count when combining queries, particularly when you use the Minus operator.

    You can change Web Intelligences default behavior so that only unique rows are returned bythe combined query.

    To retrieve only unique rows

    1. In theQuery panel, display theQuery Properties tab.

    2. In theData zone, clear the Retrieve duplicate rows option.

    Activity: Combined queries

    Objective

    Using Web Intelligence Rich Client, create a document by combining queries, using theUnion, Intersection or Minus functions.

    Instructions

    Note: To log onto Web Intelligence Rich Client, you need a user name and password for theBusinessObjects Enterprise server. Refer to your class instructor for this information.

    You want to create a query that shows a list of product lines. The list must show: Product lines that are colored Anise

    AND

    Product lines that are both Coffee colored, and also have sold a greater quantity than 450units

    Using the combined query technique, create the following table:

    Which operator will you use to combine the queries?

    Web Intelligence Advanced Report DesignLearners Guide12

  • Activity: Combined queries - Optional

    Objective

    Create a Web Intelligence document by combining queries, using the Union, Intersectionand Minus functions.

    Instructions

    You are interested in reporting on the relationship between the eFashion stores that earned atleast $3,000,000 in sales revenue and those stores whose margin was at least $1,300,000.

    Assume that you already have two reports built using the following queries: Report 1:1

    Report 2:1

    13Working with Advanced Query TechniquesLearners Guide

  • 1. Using the combined query technique, create a table showing all Store names that have bothSales revenue of $3,000,000 or higher and aMargin of $1,300,000 or higher.

    Which operator will you use to combine the queries?

    2. Once you run the combined query, apply a Count to the Store name column.

    The table should appear like this:

    3. Edit the query and update the data in the table so that it shows all Store names that havehad Sales revenue of at least $3,000,000 but not a margin of $1,300,000 or more.

    Which operator will you use to combine the queries?

    4. Once you run the combined query, check that the Count is still applied to the Store namecolumn.

    The table appears like this:

    5. Edit the query to display all Store names that have had either Sales revenue of at least$3,000,000 or aMargin of at least $1,300,000.

    Which operator will you use to combine the queries?

    6. Once you run the combined query, check that the Count is still applied to the Store namecolumn.

    Web Intelligence Advanced Report DesignLearners Guide14

  • The table should appear like this:

    7. Which of the previous results could you also achieve using multiple query filters?

    8. Save the document as Act_Combinedqueries_Opt.

    15Working with Advanced Query TechniquesLearners Guide

  • Using subqueries

    A subquery, as its name suggests, is a query within a query. It contains an inner query, whichreturns a set of data that is used as the basis for a second, outer (or main) query.

    After completing this unit, you will be able to:

    Describe subqueries Create a subquery

    Understanding subqueries

    Subqueries are used in caseswhere the results of themain query are dependent upon the resultsof the inner query. This means that the inner query must be processed first so that the resultset can be passed on the main query.

    Like combined queries, subqueries are always built in theQuery panel.

    You construct a subquery by placing a query filter on one of the objects in the main query andthen using the operand for that query filter to launch the subquery. The operator you includein the query filter determines the relationship between the data sets returned by the inner andouter queries.

    Typically you use subqueries when:

    The value of the operand is unknown.

    The query filter for the report involves a value that will change over time.

    Creating a subquery

    Now you will explore how and when to use subqueries.

    Suppose that you have been asked by the Manager of the Chicago 33rd store of the eFashionGroup to produce a report that lists stores and their revenue whenever those stores' revenueare higher than Chicago 33rd.

    Web Intelligence Advanced Report DesignLearners Guide16

  • To produce the requested report, you need to resolve an issue regarding the query filter. Thequery filter for the report involves a value that is not known prior to the query being made,and it will change over time. Since the revenue of the Chicago 33rd store changes over time,you cannot enter a hard-coded figure for the sales revenue because the user would never beable to refresh the report and get accurate results.

    To resolve this problem, you can use a subquery. Begin by creating a query using the Storename andSales revenue objects, and then, using theAdd a subquery button, create a subquery.

    By default, the Sales revenue object appears in the subquery definition in theQuery Filterspane. Since youwant your report to display the results for all stores with sales revenue greaterthan or equal to the Chicago 33rd location, change the operand in the subquery to Greater thanor Equal to. Then, complete the subquery by dragging the Store name dimension just belowthe subquery filter definition, and use this syntax:Store name Equal to e-Fashion Chicago 33rd

    When you run the query, the report returns the results for the Chicago 33rd store, as well asresults for all the other stores with equal or greater sales revenue.

    To build a subquery

    1. Add the objects that you want to appear in the query to the Result Objects pane.

    2. Select the object that you want to filter with a subquery.

    3. Click Add a subquery.

    The Add a subquery button appears in the toolbar for theQuery Filters pane.

    The subquery outline appears in theQuery Filters pane. By default the object you selectedappears as the Filter object and Filter By object.

    4. To add aWHERE condition to the subquery, drag an object to theTo filter the query... area.

    17Working with Advanced Query TechniquesLearners Guide

  • 5. Select the operator and values used to filter the object in the WHERE condition.

    You can use a standard query filter as a WHERE condition in a subquery. To do so, dragand drop the existing filter or subquery to the To filter the query... area. To copy ratherthan move the existing filter to the WHERE condition, hold down the Control key whiledragging and dropping. In this case the existing filter remains in its initial place and becomespart of the WHERE condition of the subquery.

    6. Click Subquery to add an additional subquery to the query filter.

    In addition to linking subqueries in AND or OR relationships, you can nest them (createsubquerieswithin subqueries) by dragging an existing subquery to theTo filter the query...area. In this case the inner subquery becomes part of the WHERE condition of the outersubquery. To copy rather thanmove the subquery to theWHERE condition, hold down theCtrl key while dragging and dropping. In this case the second subquery remains at thesame level as the first, and becomes part of the WHERE clause of the first.

    By default the two subqueries are linked in an AND relationship. Click the AND operatorto toggle between AND and OR.

    Activity: Using subqueries

    Objective

    Create a subquery using the results of one query as the starting point for a second query.

    Instructions

    You have been asked by the Manager of the Colorado Springs store of the eFashion Group toproduce a report that lists product lines and theirMargin, when the lines'Margin is higherthan that of the Sweaters line.

    1. Using the eFashion universe, create a new document and build a query using Line andMargin.

    2. Using the subquery technique, return those lines with a higherMargin than the Sweatersline.

    3. You also need to display a title.

    4. Save the document as Act_Subqueries.

    Web Intelligence Advanced Report DesignLearners Guide18

  • The report should look like this:

    19Working with Advanced Query TechniquesLearners Guide

  • Creating a query based on another query

    Web Intelligence allows you to create a query based on the structure of another query.Consequently, you save time with complex reports and can ensure that different queries aredefined in exactly the same way.

    After completing this unit, you will be able to:

    Duplicate a query in a document to build another query.

    Duplicating queries

    When you build a report with many queries based on the same universe, duplicating yourquery can accelerate the process, especially when the queries have some of the objects incommon.

    Suppose that you are asked to create a report for eFashion that displays state, year, and salesrevenue. The reportmust use a prompted query filter to allowusers to select the state forwhichto return the results.

    To create the query, you place the State, Year, and Sales revenue objects in theResult Objectspane of theQuery panel, and place the State object in theQuery Filters pane, using the requiredprompt.

    Next, suppose that you are asked to generate another report that prompts for state, but thatthis time displays sales revenue broken down by store and year, rather than by state and year.The query you need to create this report is almost identical to that required for the previousreport. The only difference is that in the second query, you must use the Store name object inthe Result Objects pane, where in the first query you used the State object.

    To save yourself the effort of creating an entirely new query to generate the second report, youcan duplicate the first query, delete the State object in the Result Objects pane, and replace itwith the Store name object. When you run the new query, it produces the results you require.

    Web Intelligence Advanced Report DesignLearners Guide20

  • To duplicate a query

    1. Select the query you want to duplicate by right-clicking the appropriateQuery tab at thebottom of theQuery panel.

    2. SelectDuplicate Query.

    A duplicate query appears in theQuery panel, and its tab is labeled (1).

    You can now modify the query.

    21Working with Advanced Query TechniquesLearners Guide

  • Changing data sources

    Web Intelligence allows you to change the data source used to create a document:

    From one universe to another universe From a local data source to a universe

    You cannot change data sources from a universe to a local data source.

    After completing this unit, you will be able to:

    Change the data source for a document Map the objects to the new data source

    About changing data sources

    With theWeb Intelligence query interface, you can change the data source for your querywhenrequired.

    This is particularly useful when:

    You move a test universe into production and want to use the same documents on the newuniverse. For example, you can change the test universe stores to the production universeeFashion.

    You change between different universes covering different functional areas but based onthe same database.

    For example, an organization has a Marketing universe and a Sales universe based on theSales database. The Marketing universe uses objects for companies, contacts, leads, andpromotional efforts. The Sales universe uses objects for companies, contacts, sales orders,and sales revenue.

    TheMarketingmanagerswant to knowhowmany contacts establishedduring a promotionalcampaign actually led to sales within the six months following the campaign.

    With appropriate access to the Sales universe, the managers can take a query that retrievesthe companies and contacts that participated in the campaign, change the universe fromMarketing to Sales, add the Sales Revenue object from the Sales universe to the query andfilter to retrieve data for the six-month period following the campaign.

    To change the data source

    1. From your document in theWeb Intelligence Rich Clientmain window, click the EditQuery button.TheQuery panel displays.

    Web Intelligence Advanced Report DesignLearners Guide22

  • For a document built on a local data source, the data source appears in theQuery Propertiessection of the left-hand panel.

    For a document built on a universe, click the Properties tab. TheUniverse field appears onthe Properties tab.

    2. To change the data source:

    For a document built on a universe, next to the Universe field, click the (ellipsis)button.

    TheUniverse dialog box displays with a list of the universes that you can use to replacethe current one.

    For a document built on a local data provider, next to the Source file field, click the(ellipsis) button.

    The Choose File dialog box displays for you to browse to a new local data source.

    3. To select the new data source:

    In the Universe dialog box, click to select the universe and click theOK button. In the Choose File dialog box, browse to select the local data source and click theOpen

    button.

    TheChange Source dialog box displays to show you how the objects from the query on theoriginal data sourcemap to objects in the newdata source. The first column shows the object

    23Working with Advanced Query TechniquesLearners Guide

  • from the original query, or the source object, and the second column shows the object in thenew data source, or the target object.

    Web Intelligence proposes mapping to objects based on the object name and data type.

    The check mark to the left of the object names indicates that the object is mapped toanother object in the new data source.

    The X to the left of the object name indicates that the object is removed from the queryon the new data source.

    The check mark to the left of the object names indicates that the object is mapped toanother object in the new data source.

    The X to the left of the object name indicates that the object is removed from the queryon the new data source.

    4. Optionally, to modify the proposed mapping or removal of an object, click the ... (ellipsis)button on the line corresponding to the object for which you want to modify the mapping.

    Web Intelligence Advanced Report DesignLearners Guide24

  • TheMap Object dialog box displays.

    In theMap Object dialog box:

    To remove the object, select the Remove object option . To map to a new object, select the Select a new object option and click the object from

    the new data source displayed in theMap Object dialog box.

    5. ClickOK to close theMap Object dialog box.

    6. Repeat steps 5 and 6 for each object with a proposed mapping or removal that you want tochange.

    7. ClickOK to close the Change Source dialog box.In theQuery panel, in the Properties tab, the Universe field shows the new data source.The Result Objects pane shows the objects for the new data source.

    8. Click Run Query.The results of the query on the newdata source display in theWeb Intelligence Rich Clientmain window.

    9. Save the document.

    Activity: Changing the data source

    Objective

    In this activity, you change the data source from the development universe (stores) to theproduction universe (eFashion).

    25Working with Advanced Query TechniquesLearners Guide

  • Instructions

    1. From the course resources, open the Sales per Region.wid document. This document wascreated using the stores universe.The report looks like this:

    2. Change the data source to the eFashion universe and map the objects as appropriate.

    To achieve the desired results, remove one object from the query and map another objectto a corresponding object in the new universe that has a different name.

    Web Intelligence Advanced Report DesignLearners Guide26

  • The report looks like this:

    27Working with Advanced Query TechniquesLearners Guide

  • Quiz: Advanced Query Techniques

    1. What are the three types of query techniques used in this lesson?

    2. If you were to use the UNION operator to combine queries, what would be the result?

    3. If you were to use the INTERSECTION operator to combine queries, what would be theresult?

    4. If you were to use the MINUS operator to combine queries, what would be the result?

    5. List two reasons why you might want to use combined queries.

    6. Can you do a subquery and return exactly the same results as a combined query?

    7. Which subquery operand type means that Web Intelligence will look for only one instanceof a value from the subquery that meets the query filter? a. ALL b. ANY

    8. Why would you choose to do a combined query rather than a subquery?

    9. When you change a data source, what can you choose to do to the objects in the originalquery?

    Web Intelligence Advanced Report DesignLearners Guide28

  • Lesson summary

    After completing this lesson, you are now able to:

    Use combined queries Use subqueries Create a query based on another query Change data sources

    29Working with Advanced Query TechniquesLearners Guide

  • Web Intelligence Advanced Report DesignLearners Guide30

  • Lesson 3Working with Calculation Contexts

    Lesson introduction

    This lesson provides information on howWeb Intelligence performs calculations in reports.By default, Web Intelligence determines the result of a measure when it is projected in thereport based on the dimension(s) in the part of the report where the measure is inserted (forexample, in columns of a table). These dimensions make up what is called the calculationcontext of the measure object or variable.

    When you understand the default behavior of contexts, you can also understand how tomanipulate the contexts and force a report to display data in themanner you specify regardlessof the other objects projected.

    This lesson demonstrates how to use various operators and keywords to define and redefinecontexts in your calculations.

    After completing this lesson, you will be able to:

    Understand calculation contexts Redefine calculation contexts

    31Working with Calculation ContextsLearners Guide

  • Understanding calculation contexts

    This unit introduces key concepts of calculation contexts in Web Intelligence. Calculationcontext is the way that Web Intelligence dynamically calculates values projected in a report bymeasure objects or variables.

    In aWeb Intelligence document,measures are calculated dynamically based on the dimensionswith which they appear. For this reason, it is important to understand that Web Intelligence,by default, performs calculations at the row level and at the lowest level dimension availablein your block.

    After completing this unit, you will be able to:

    Explain howWeb Intelligence calculates data dynamically Explain the impact of input and output contexts on how data is calculated Explain how you can use extended syntax to change the default calculation context

    Dynamic calculations

    By default, when objects are placed in a block, the projected values of the measures areaggregated to the level of the dimensions displayed in the block, as opposed to the level of thevalues as stored in the data provider.

    For instance, if you create a table showing Year and Sales revenue, the measures will beaggregated to the Year level, as shown in the first table.

    If you added State to the beginning of the table then the Sales revenue would be aggregatedby year for each state, as shown in the second table.

    Web Intelligence Advanced Report DesignLearners Guide32

  • When you remove a dimension from the table (Year, in this case), as in the third table in thediagram, Web Intelligence automatically recalculates the sales revenue data according to thenew context (State, in this case).

    You can see in this example that sales revenue is calculated at the row level. InWeb Intelligence,this row level calculation is the default calculation context for any measure object or variableplaced in a column.

    If you set a section on a report, any measures inserted at the section level are calculated bydefault using the section as the calculation context.

    In this example, the report is sectioned by state. Beside the section heading is a cell displayingsales revenue at the state level. Notice that the sales revenue value at the state level matchesthe sum of sales revenue results for all of the stores in the state.

    Similarly, if you insert a sales revenue cell beside the report title, the calculation context is thewhole report, so the cell displays the sales revenue grand total.

    33Working with Calculation ContextsLearners Guide

  • These examples demonstrate the first way of controlling a calculation, where the level ofaggregation is affected by the environment of the report:

    The projected values of a measure are aggregated to the level of the dimensions displayedin the block.

    The position of the measure within the body of the report can also control the aggregationlevel. If a report is sectioned and you place a measure at the section level of the report, theprojected value of the measure will be aggregated at the dimension level on which thesection is based.

    The second way of controlling a calculation is to force a level of aggregation other than thedefault. For example, you can place a variable or a formula in a table, but force it to aggregateto the sum of all values for the table. Such functionality is required if you are going to createpercentage calculations across sectioned reports.

    The remainder of this lesson demonstrates how to force the level of aggregation for measurevalues when you project the values in a report.

    Web Intelligence Advanced Report DesignLearners Guide34

  • Redefining calculation contexts

    This unit provides reasons why you might choose to redefine the input or output contexts ofmeasures in your report. It also provides examples of the logic to apply when you redefine theinput or output contexts.

    These examples show how to use both extended syntax context operators and keywords.

    After completing this unit, you will be able to:

    Explain the impact of input and output contexts on how measures are calculated Define the input context in order to change the level of aggregation Define the output context in order to change the level of aggregation Use the In context operator with Where to redefine a calculation context

    Input and output contexts

    Input and output contexts must be added to a calculation if you want the context of thecalculation to be something other than the default context.

    Input context consists of any dimension objects that need to be included directly IN thecalculation itself.

    Output context consists of one or more dimension objects that determine where thecalculation is placed in the report, or in other words, the level where the calculation is to beturned OUT in the report.

    In fact, the output context determines at what aggregation level the calculation is displayed(for example, a master variable in a section).

    Consider the simple calculation shown here:= Sum([Sales revenue])

    There are no dimension objects in the calculation itself, so the input context is the sum of thevalues returned by the measure object Sales revenue. This calculation does not specify anoutput context, so Web Intelligence assumes the default context and uses the dimensions withwhich the measure appears.

    35Working with Calculation ContextsLearners Guide

  • As no output context is specified for the Sum calculation, it assumes the context of State.

    Note: It's important to understand that you can only set the context to a level that exists within thedata provider of the document. For example, if youwanted to change the default context to calculatesales revenue at the city level, the City object must exist in the data provider.

    You cannot show data at the city level if the query does not include this object in the dataprovider.

    Forcing the input calculation context

    You have seen how to use the default calculation context. You can determine what dimensionswill be taken into account when calculating the aggregate for the formula. This is referred toas the input calculation context. Typically, you would want to use this when the calculationneeds to take into account specified dimensions that may not appear in the report, but arecontained within the data provider.

    Suppose that you want to create an eFashion report that displays each state, its total revenue,and the best revenue ever achieved in any one year. To understand how to create a variablethat returns the best revenue achieved in any one year by state, it helps to begin by looking ata report that shows sales revenue by year, grouped by state.

    The Sales revenue column is sorted in descending order, so the top entry in the Sales revenuecolumn is what you would like to create a variable to identify. Since you don't want your finalreport to contain a Year column, you can now insert a new table that contains only the Stateand Sales revenue objects.

    Web Intelligence Advanced Report DesignLearners Guide36

  • Now you just need to create a variable that returns the state's best year amount and insert it inthe new table. As your first attempt, youmight create a variable calledState's best year amount,using this syntax:=max([Sales revenue])

    If you add the new variable to the table, you get this result:

    If you compare the state's best year revenue shown in the first block with the data calculatedby the variable you have just created, you can see that the default behavior of the calculation,at the row level, is obviously not the correct context.

    By default, Web Intelligence does not know that the Year object needs to be included in thecontext of the calculation - it uses State as the context to calculate the values, and the result isthe exact same calculation that the Sales revenue object projects.

    Now, extend the syntax to specify the correct input and output context so thatWeb Intelligenceknows how to calculate the data correctly. The syntax for specifying input and output contextis:

    Aggregate function([Measure] input_context) output_context

    To extend the syntax, the available operators are: ForEach In

    37Working with Calculation ContextsLearners Guide

  • The key syntactic difference between an input and an output context is where the operator isplaced. In an input calculation context, the operator is placed within the brackets of theaggregate:

    Syntax: Aggregate(measure FOREACH (dimension list))

    For example: =Max([Sales revenue] ForEach ([Year]))

    Or

    Syntax: Aggregate(measure IN (dimensionlist))

    For example: =Max([Sales revenue] In ([Year]))

    Suppose that you modify the State's best year amount variable to use this formula:

    =Max([Sales revenue] In ([Year]))

    The report now looks like this:

    This formula does notwork because although it includesYear in the calculation context, it doesnot include State. Even though the table includes a State column, and you would normallyexpect the data to aggregate to the state level, the In operator only takes into account dimensionsin the formula's dimension list. Now you can modify the variable to use this formula:

    =max([Sales revenue] In([Year] ; [State]))

    The report looks like this:

    Web Intelligence Advanced Report DesignLearners Guide38

  • This formula achieves the desired result. By default,Web Intelligence takes [state] as the outputcontext.

    You can create an alternate formula for the variable by using the ForEach operator instead ofIn. Unlike the In operator, the ForEach operator takes into account all the dimensions in thetable, so you can achieve the same result using this formula:

    =max([Sales revenue] ForEach ([Year]))

    About the extended syntax operators and keywords

    The extended syntax available to redefine the calculation context of measures includes:

    Extended projection context operators, including In, ForEach, and ForAll. Extended environment keywords, including Report, Section, Break, Block, and Body. These

    keywords are used in formulas in conjunction with the In context operator.

    The context operators that are available to redefine the calculation context ofmeasures include:

    DefinitionOperator

    Used to specify dimensions explicitly. Also used with extendedsyntax keywords.

    In

    Specifies limiting conditions on the data.Where

    Adds dimensions to the context.ForEach

    Removes dimensions from the context.ForAll

    The ForAll and ForEach operators are useful when you have a default context with manydimensions. It is often easier to "add" or "subtract" from the context using ForAll and ForEachthan it is to specify the list explicitly using In.

    39Working with Calculation ContextsLearners Guide

  • Forcing the output calculation context

    In the previous examples, you considered the input calculation contexts. That is, you consideredhow you wanted the measure to aggregate based on the dimensions available in the table andthe data provider.

    You can also determine the level of aggregation at which the value for the variable is displayedin the report.

    The extended syntax keywords, Report, Section, Break, Block, and Body are useful in definingcalculation context. These keywords, used in conjunction with the In operator, allow you tochange the default context from the row level to another level in the document.

    Suppose that you want to create a report that contains an alerter which highlights any storewhose revenue for the year 2006 is lower than the average revenue of all stores in 2006. Youbegin with this report:

    Now you want to create a formula that returns the average sales revenue, so you can use thevariable in your alerter. If you click on the Average value in the footer at the bottom of the tableand look in the Formula toolbar, you see that the footer uses this calculation:

    =Average([Sales revenue])

    This calculation is generic; it has no input or output context specified. It returns a correct averageof revenue earned by stores because no other specific contextwas defined. The calculation usedthe default context of the table footer, which contains calculations based only on data thatresides in the block (the table, in this case).

    Note: If a report filter is applied to the table, the default context in the table footer calculatesonly the values retained by the filter.

    If you create anAverage variable using the same syntaxWeb Intelligence used to calculate theaverage for all stores, and add a new Average column to the table, you get this result:

    Web Intelligence Advanced Report DesignLearners Guide40

  • The Average variable appears in the table, but the values are now calculated at the row levelrather than at the whole table level.

    Why is this happening? The default calculation context has changed.

    When the formula =Average([Sales revenue]) is placed in: The footer: the context is to calculate for the entire table. The table: the context is to calculate for each individual row.

    If you try to build an alerter to highlight values in the Sales revenue column that are belowthe average, the alerter will not work since the Sales revenue values are currently equal to theAverage values.

    To solve this, you can use either the ForAll or the In Block operators, using the following syntax:

    Aggregate(measure) ForAll(dimensionlist))

    For example: =Average([Sales revenue]) ForAll ([Store name];[Year])

    Or

    Syntax: Aggregate(measure) In Block

    For example: =Average([Sales revenue]) In Block

    The difference between the two is that the ForAll operator only aggregates the measure for thedimensions in the dimension list, while the In operator aggregates at the report environmentlevel, that is, at the body, block or report level.

    The key difference is that when you use the In operator, the formula calculation is aggregatedat the specified level regardless of which dimensions or variables are used in the report.

    If you update theAverage formula to use the =Average([Sales revenue]) In Block formula,the report looks like this:

    41Working with Calculation ContextsLearners Guide

  • Why use this syntax?

    By adding In Block as the output context, you are specifying that the calculation should bedisplayed at the block (whole table) level, even though the calculation was placed at the rowlevel.

    Why is there no input context?

    No input context is needed since the calculation needs to find the average based on the entiretable. By leaving the input context to assume the default, you ensure that no additional objectsare considered when the average is calculated.

    Now that theAverage variable uses the correct formula, you can create the alerter to highlightbelow average results per store.

    If you apply this alerter to the Store name column in the report, and remove the Averagecolumn, you get the results you require:

    Web Intelligence Advanced Report DesignLearners Guide42

  • More about the extended syntax keywords

    The following keywords can be usedwith the In operator to control howmeasures are calculatedat different levels within the document: Report, Section, Break, Block, and Body.

    EffectEnvironment Level

    The projected value of themeasure is aggregated for all dimensionscontained within the page of the report.

    Report

    The projected value of themeasure is aggregated for all dimensionscontained within the section of the report.

    Section

    The projected value of themeasure is aggregated for all dimensionscontained within the break of the table.

    Break

    The projected value of the measure is aggregated across all valuesfor dimensions contained within the block.

    Block

    The projected value of themeasure is aggregated for all dimensionsat the level in the report that it is placed.

    Body

    Input vs. output calculation contexts

    In summary, unless you need the aggregate of a measure to take into account a dimension thatis in the data provider but not in the table, an output calculation will suffice.

    43Working with Calculation ContextsLearners Guide

  • When specifying an output calculation context, it is normally best to use the In operator as thisis more flexible and will not need to be changed if the dimensions of the environment arealtered.

    Conversely,when specifying an input calculation context, it is normally better to use the ForEachoperator as it will automatically take into account the dimensions in the block.

    Using the In context operator with Where

    Two of the most widely-used operators used to specify both input and output contexts are Inand Where. Although each operator denotes a different type of calculation environment, thetwo may be used together in a single variable.

    The In operator specifies all parameters (dimension objects) that are to be included in thecontext. When using multiple dimension objects, the dimensions should be listed in order ofgranularity and must be separated with ";".

    The Where operator instructs the variable to calculate only where certain values are true.

    Suppose that you need to produce a report that calculates both the highest sales revenue forall states as well as specific information for California. You start out creating a query includingthe Year, State, and Sales revenue objects, and remove the State column from the table so thatyour report looks like this:

    Web Intelligence Advanced Report DesignLearners Guide44

  • Now you can create a Sales revenue By Year for California variable using this syntax:

    =[Sales revenue] Where ([State]="California")

    This context uses the Where operator to isolate the California state in the calculation. If youreplace the Sales revenue column with this new variable, and apply some formatting to thetable, it looks like this:

    Now you want to create a variable to find the highest revenue for any one state. You can usethis syntax:

    =Max([Sales revenue] In([State]))

    This context uses the In operator to specify input context. This assures that the calculation onlyaddresses the State values when locating a maximum amount.

    There is no output context defined, so the calculation uses the default output context of theentire report, because it was placed at the report level rather than in a table.

    Next you can create a Highest annual revenue for California variable using the followingsyntax:

    =Max([Sales revenue] In([State];[Year]) Where([State] ="California"))

    This variable definition uses both the In andWhere operators to achieve the correct calculation.Both operators were used in defining the input context.

    The In operator forces the =Max operator to look in the State values first and then the Yearvalues within each State in order to locate the maximum value.

    The Where operator assures that the =Max calculation is only valid where the state isCalifornia.

    Finally, you can create a Sales revenue for California for the 2006 variable using this syntax:

    =[Sales revenue] Where([State]="California" And [Year] ="2006")

    Like the Sales revenue ByYear for California variable, this calculation uses theWhere operatorin the input context to ensure that the calculation is valid for only those values denoted by theWhere operators.

    It is not necessary to list the components of the calculation in order of granularity when usingthe Where operator. You must list the components when using the In operator.

    The following table shows syntax and examples for the Where operator.

    45Working with Calculation ContextsLearners Guide

  • Syntax and Examples:Description:Operator:

    [measure_expression] Where [boolean_expression]Restricts the dataused to calculate

    Where

    The formula Average ([Sales Revenue]) Where ([Country]= "US") calculates the average sales where the country is "US".the measure

    expression.The formula Average ([Sales Revenue]) Where ([Country]= "US" Or [Country] = "France") calculates the average saleswhere the country is "US" or "France".

    The formula [Revenue] Where (Not ([Country] Inlist("US";"France"))) calculates the revenue for the countriesother than US and France.

    The variable [High Revenue] has the formula [Revenue] Where[Revenue> 500000].

    When placed in a block, [High Revenue] displays either therevenue when its value is greater than 500000, or nothing.

    When placed in a footer at the bottom of the [High Revenue]column, the formula Average ([High Revenue]) returns theaverage of all the revenues greater than 500000.

    Note: You can use the boolean operators with theWhere operator.

    Important facts about calculation contexts

    If you do not define an input or output context,Web Intelligence assumes the default contextof where the calculation has been placed.

    When using variables as the basis of an alerter (as in the Average example just seen), it isnecessary to ensure that the calculation has been created as a variable (that is, a formulawith a name), and not as a simple formula.

    Note: If the calculation is a formula, show the Formula toolbar, then click theCreateVariablebutton in order to save it as a variable.

    When using theWhere operator, it is necessary to place parentheses around the values listedafter the Where , as in the following example:

    =[Sales revenue] Where ([Year] = "2004)

    Activity: Calculation contexts

    Objective

    Use extended syntax to redefine the calculation context of measures in a Web Intelligencedocument.

    Web Intelligence Advanced Report DesignLearners Guide46

  • Instructions

    1. Create a document that shows in a single block:

    Sales revenue for each eFashion store. Total sales revenue for all stores. Average revenue for all stores. Highlight those stores whose revenue was above the average revenue for all stores.

    2. Change the name of the report to Revenue Information for All Stores.

    3. Save the document as Act_Calculationcontext.

    Your document should look like this example:

    Activity: Calculation contexts - Optional

    Objective

    Use extended syntax to redefine a calculation context of measures in a Web Intelligencedocument.

    Instructions

    1. Create a document that shows in a single block:

    Sales revenue per Year, broken down by Store name.

    47Working with Calculation ContextsLearners Guide

  • The maximum revenue per store, over the three year period. Highlight the store name when this maximum revenue value is greater than $1,000,000.

    2. Save the document as Act_Calculationcontext_2.

    Your document should look like this example:

    Web Intelligence Advanced Report DesignLearners Guide48

  • Quiz: Calculation Contexts

    1. What is an input context?

    2. What is an output context?

    3. Which of the following is an extended syntax context operator? NoFilter() ForEach Block

    4. Which of the following is an extended syntax keyword? NoFilter() ForEach Section

    49Working with Calculation ContextsLearners Guide

  • Lesson summary

    After completing this lesson, you are now able to:

    Understand calculation contexts Redefine calculation contexts

    Web Intelligence Advanced Report DesignLearners Guide50

  • Lesson 4Creating Formulas with Character and Date StringFunctions

    Lesson introduction

    The ability to create formulas and define them as variables inWeb Intelligence offers the reportdesigner a very powerful tool. Variables act just like dimension or measure objects. Once youhave created a variable, you can use it throughout the document to display data that you cannotretrieve by using the existing objects in the universe.

    In this lesson, you learn about some of the formula functions available formanipulating characterand date variables. While the syntax may take some time to comprehend, it is well worth theeffort as variables can provide you with more flexibility in reporting.

    Note: For more information about creating formulas and defining them as variables, refer tothe BusinessObjects Web Intelligence XI 3.0/3.1: Report Design course.

    After completing this lesson, you will be able to:

    Use character strings Use the Right() function Use the Replace() function Use the SubStr() function Use the Pos() function Concatenate different character strings Use date functions

    51Creating Formulas with Character and Date String FunctionsLearners Guide

  • Using character strings

    A character string is a series of characters that form either a piece of text or the individual valuesof a character-type variable. They are always categorized as dimension objects, but the reverseis not true. A dimension object can be of character, date, or numeric type.

    Using Web Intelligence character-string functions, you can replace, modify, or remove eitherall or part of a character string.

    After completing this unit, you will be able to:

    Describe the character-string functions presented in this lesson

    About character-string functions

    The character-string functions presented in this lesson are:

    Right() - used to extract a given number of characters from the right

    Replace() - used to replace a specified string with another string

    Left() - used to extract a given number of characters from the left

    SubStr() - used to extract a string from within a string using variable length and position

    Length() - used to identify the length of a string

    Pos() - used to identify the position of a character in a string

    Replace() , Right(), and Left() are only useful when you want to manipulate a constant stringor a constant number of characters. SubStr() is a more powerful function. You will use theSubStr() function to extract strings where the length and position are not consistent.

    Using functions in formulas and variables

    You use the functions presented in this lessonwhen you are creating a formula. You can createa formula by typing it in the Formula bar or in the Formula Editor . Either method calculatesthe data and displays the resulting values in the column that you have highlighted in the block.

    You can also drag and drop objects in the Formula bar and then complete the formula by typingin the Formula bar.

    If youwant to use the formula repeatedly in different blocks or different reports in the document,or if you want to identify the formula as though it were an object in the document, you candefine the formula as a variable.

    If you only want to display the calculated value in a single cell, then creating a formula is best.However, if you want to display the result as a column in a report block, then defining theformula as a variable is best.

    If in doubt, always create a variable rather than a formula, as there are certain things that cannotbe done with a formula that can be done with a variable.

    Web Intelligence Advanced Report DesignLearners Guide52

  • Using the Right() function

    The Right() function displays a fixed number of characters starting from the right end of thecharacter string and removes the others.

    The syntax for the Right() function is:

    string Right(string input_string; integer number_of_characters)

    input_string refers to the string from which you want to select characters to display.

    number_of_characters sets the number of characters to display from the right of the inputstring.

    After completing this unit, you will be able to:

    Use the Right() function to display selected characters from a character string

    How to extract characters using the Right() function

    Suppose that you are working with this report:

    The Year object in the eFashion universe is formatted to return the year as a four-digit number(for example, 2004). However, you need to display the year in two-digit format (for example,04). To do this, you can use the Right() character string function to remove the first two digitsand display the last two.

    Create a new variable called Years, using this syntax:=Right([Year] ; 2)

    where:

    53Creating Formulas with Character and Date String FunctionsLearners Guide

  • DescriptionSyntax

    The name of the object that retrieves the data.[Year]

    The number of characters to display from theright of the character string.

    2

    Note: The Left character string function works in exactly the same way except that the functiondisplays the specified number of characters starting from the left.

    When you drop the Years variable in the section header block, the report looks like this:

    To further clarify the section header, you can modify the Years formula to use this syntax:=NameOf ([Year]) + " " + Right([Year] ; 2)

    where:

    DescriptionSyntax

    To display the name of the Year object.NameOf([Year](

    To concatenate a space after the object name.+

    To concatenate and display two characters starting from the rightend of the character string.

    + Right ([Year]) ;2 )

    The report looks like this:

    Web Intelligence Advanced Report DesignLearners Guide54

  • 55Creating Formulas with Character and Date String FunctionsLearners Guide

  • Using the Replace() function

    The Replace() function replaces a specified string with another string.

    The syntax for the replace function is:

    string Replace(string input_string; string string_to_replace; stringreplace_string)

    input_string The input string.

    string_to_replace The string within input_string to be replaced.

    replace_string The string to replace string_to_replace with.

    After completing this unit, you will be able to:

    Use the Replace() function to replace Q with the word Quarter

    Replacing a string

    Suppose that you need to report on quarterly revenue using the word Quarter instead of Q inthe report.

    You can create a variable using the Replace() function to modify the character string displayedin the report using this formula:=Replace([Quarter] ; Q ; Quarter )

    where:

    DescriptionSyntax

    The name of the object that retrieves the data.[Quarter]

    Web Intelligence Advanced Report DesignLearners Guide56

  • DescriptionSyntax

    The value stored in the database, followedby 1 through 4 to indicate the first throughfourth quarters of the year.

    Q

    The character string that will replace Q inevery instance.

    Quarter Note: Be sure to add a space after the word Quarterand before the end-quote.

    If you replace the Quarter column with the new variable you created, you get this result:

    57Creating Formulas with Character and Date String FunctionsLearners Guide

  • Using the SubStr() function

    The SubStr() function extracts a specified character string from within a string.

    The syntax for the SubStr() function is:

    string Substr(string input_string; integer start; integer length)

    input string is the string from which the substring is to be extracted.

    start is the position of the first character in the input string to be extracted (for example, 1).

    length is the number of characters (from the initial position forward) to be extracted.

    After completing this unit, you will be able to:

    Use the SubStr() function to extract a character string from within a string

    How to extract characters using the SubStr() function

    The Store name object in the eFashion universe returns the name of each store in the company,but prefaces each one with "e-Fashion".

    Suppose that you want to remove the e-Fashion portion of the character string. This presentsa challenge since the length of each store's name is different, with or without the "e-Fashion"portion. Neither the Right() or Left() functions will work here.

    The easiest way to achieve the removal is to use the SubStr() function. Create a variable calledStore, and use this syntax:=SubStr([Store name] ; 11 ; Length([Store name]))

    Why?

    "11" represents the starting point at which the formula is to start displaying characters. Thiswas established by counting the number of characters in "e-Fashion" (9) and then adding a

    Web Intelligence Advanced Report DesignLearners Guide58

  • character to account for the space between the word "e-Fashion" and each store name (10).Therefore you want the starting point to be character 11.

    The Length() function returns the length of the original store name, including the e-Fashionpart of the name.

    Note: Dont forget that the beginning number in the SubStr() function is the beginning characterposition that you want the substring to start displaying characters. Character positions identifiedin the SubStr() syntax are those you want to see displayed, not those you want to remove.