Page 1

Using combined queries to 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 a single block in a document. Note: This technique is presented in the BusinessObjects Web Intelligence XI 3.0/3.1: Report Design 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 results of 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 different from synchronizing multiple data providers using merged dimensions. About combined query functions Adding single and complex query filters to a query allows you to restrict the amount of information returned by the query. This standard technique allows you to combine multiple filters in a single query, and these combinations can be designed to make queries very specific and limiting. However, this technique only works with a single query. There may be situations when you want to combine the results of two queries into a single block.


To accomplish this, you must build a combined query. All combined queries are built in the Query panel, and can only be built using a single universe. Each query needs to have the same number 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 would run separate SQL statements for each object and then return the data in different blocks (tables). A union query forces Web Intelligence to return the data from both objects together in one column. Unions, when used to combine the results of two queries using the same objects, will remove duplicate 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 union query, Web Intelligence considers each select statement separately and combines their results in the end. Unlike a union query, the intersection query only returns those values that are in both queries. In this sense, it works much the same as using the AND operator when creating a regular query with multiple query filters. • Minus: combine results which include everything in Query 1 except for what is also true in

You use a minus query to exclude the results of one query from the main query result (Query 1). For example, a minus query could be used to find out which customers bought product A but not product B. You could not obtain this data with standard query filters since the result sets need to be obtained separately before being combined. Like a union query, the minus query considers each query separately and combines their results in the end. When you build minus queries, you must pay attention to the order of the queries, since the 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 their invoices. 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 the dates is incompatible and therefore, the objects are incompatible. Since the objects are incompatible, if you include them in a standard query, Web Intelligence returns 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 the first query and Reservation 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 you may have used when combining conditions in a single query. The Intersection function is similar in effect to AND; the Union function is similar in effect to OR; the Minus function is similar in effect to NOT. However, the column of data retrieved by the combined query displays a header that reflects the date object from the first query only. In other words, using the example above, the query returns a column entitled Invoice Date, but the column actually contains both invoice dates and reservation dates. This is important to understand, as it may require you to reformat the column header. Advantages of using combined queries There are a number of reasons why you may want to use combined queries instead of applying multiple 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 creating multiple 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 need often depends on how the data is structured in your database. Using the combined query technique The combined query technique combines the results of one query with the results of another query into a single query, or data provider. The manner in which the data is combined depends on the function you choose: Union, Minus, or Intersection . Web Intelligence adds a copy of the initial query to the data provider. The second query has 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. 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). • 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, the values 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 a UnionAll) and to return all values less the duplicates. You need to define a custom formula or 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 Intelligence automatically returns all rows, even if they are repeated. This default behavior may cause an inaccurate count when combining queries, particularly when you use the Minus operator. You can change Web Intelligence’s default behavior so that only unique rows are returned by the combined query. Using subqueries A subquery, as its name suggests, is a query within a query. It contains an inner query, which returns a set of data that is used as the basis for a second, outer (or main) query. Understanding subqueries Subqueries are used in cases where the results of the main query are dependent upon the results of the inner query. This means that the inner query must be processed first so that the result set can be passed on the main query.


Like combined queries, subqueries are always built in the Query panel. You construct a subquery by placing a query filter on one of the objects in the main query and then using the operand for that query filter to launch the subquery. The operator you include in the query filter determines the relationship between the data sets returned by the inner and outer 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 Suppose that you have been asked by the Manager of the Chicago 33rd store of the eFashion Group to produce a report that lists stores and their revenue whenever those stores' revenue are higher than Chicago 33rd. To produce the requested report, you need to resolve an issue regarding the query filter. The query 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 be able to refresh the report and get accurate results. To resolve this problem, you can use a subquery. Begin by creating a query using the Store name and Sales revenue objects, and then, using the Add a subquery button, create a subquery. By default, the Sales revenue object appears in the subquery definition in the Query Filters pane. Since you want your report to display the results for all stores with sales revenue greater than or equal to the Chicago 33rd location, change the operand in the subquery to Greater than or Equal to. Then, complete the subquery by dragging the Store name dimension just below the 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 as results for all the other stores with equal or greater sales revenue. In addition to linking subqueries in AND or OR relationships, you can nest them (create subqueries within subqueries) by dragging an existing subquery to the To filter the query... area. In this case the inner subquery becomes part of the WHERE condition of the outer subquery. To copy rather than move the subquery to the WHERE condition, hold down the Ctrl key while dragging and dropping. In this case the second subquery remains at the same 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 operator to toggle between AND and OR. 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 are defined in exactly the same way. Duplicating queries When you build a report with many queries based on the same universe, duplicating your query can accelerate the process, especially when the queries have some of the objects in common. 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. About changing data sources With the Web Intelligence query interface, you can change the data source for your query when required. This is particularly useful when: • You move a test universe into production and want to use the same documents on the new universe. For example, you can change the test universe stores to the production universe eFashion. • You change between different universes covering different functional areas but based on the same database. Understanding calculation contexts This unit introduces key concepts of calculation contexts in Web Intelligence. Calculation


context is the way that Web Intelligence dynamically calculates values projected in a report by measure objects or variables. In a Web Intelligence document, measures are calculated dynamically based on the dimensions with 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 available in your block. Dynamic calculations By default, when objects are placed in a block, the projected values of the measures are aggregated to the level of the dimensions displayed in the block, as opposed to the level of the values as stored in the data provider. The second way of controlling a calculation is to force a level of aggregation other than the default. For example, you can place a variable or a formula in a table, but force it to aggregate to the sum of all values for the table. Such functionality is required if you are going to create percentage calculations across sectioned reports. The remainder of this lesson demonstrates how to force the level of aggregation for measure values when you project the values in a report. Input and output contexts Input and output contexts must be added to a calculation if you want the context of the calculation to be something other than the default context. • Input context consists of any dimension objects that need to be included directly IN the calculation itself. • Output context consists of one or more dimension objects that determine where the calculation is placed in the report, or in other words, the level where the calculation is to be turned 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).

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


Forcing the input calculation context You have seen how to use the default calculation context. You can determine what dimensions will be taken into account when calculating the aggregate for the formula. This is referred to as the input calculation context. Typically, you would want to use this when the calculation needs to take into account specified dimensions that may not appear in the report, but are contained within the data provider. 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 of measures include

The ForAll and ForEach operators are useful when you have a default context with many dimensions. It is often easier to "add" or "subtract" from the context using ForAll and ForEach than it is to specify the list explicitly using In. More about the extended syntax keywords The following keywords can be used with the In operator to control how measures are calculated at different levels within the document: Report, Section, Break, Block, and Body.


Input vs. output calculation contexts In summary, unless you need the aggregate of a measure to take into account a dimension that is in the data provider but not in the table, an output calculation will suffice. When specifying an output calculation context, it is normally best to use the In operator as this is more flexible and will not need to be changed if the dimensions of the environment are altered. Conversely, when specifying an input calculation context, it is normally better to use the ForEach operator as it will automatically take into account the dimensions in the block.


Important facts about calculation contexts • If you do not define an input or output context, Web Intelligence assumes the default context of where the calculation has been placed.


• When using variables as the basis of an alerter (as in the Average example just seen), it is necessary to ensure that the calculation has been created as a variable (that is, a formula with a name), and not as a simple formula. Note: If the calculation is a formula, show the Formula toolbar, then click the Create Variable button in order to save it as a variable. • When using the Where operator, it is necessary to place parentheses around the values listed after the Where , as in the following example: =[Sales revenue] Where ([Year] = "2004”) The ability to create formulas and define them as variables in Web Intelligence offers the report designer a very powerful tool. Variables act just like dimension or measure objects. Once you have created a variable, you can use it throughout the document to display data that you cannot retrieve by using the existing objects in the universe. In this lesson, you learn about some of the formula functions available for manipulating character and date variables. While the syntax may take some time to comprehend, it is well worth the effort as variables can provide you with more flexibility in reporting. Note: For more information about creating formulas and defining them as variables, refer to the BusinessObjects Web Intelligence XI 3.0/3.1: Report Design course. Using character strings A character string is a series of characters that form either a piece of text or the individual values of a character-type variable. They are always categorized as dimension objects, but the reverse is 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 either all or part of a character string. 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 string or a constant number of characters. SubStr() is a more powerful function. You will use the SubStr() 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 lesson when you are creating a formula. You can create a formula by typing it in the Formula bar or in the Formula Editor . Either method calculates the 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 typing in the Formula bar. If you want 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 can define 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 the formula as a variable is best. If in doubt, always create a variable rather than a formula, as there are certain things that cannot be done with a formula that can be done with a variable. Using the Pos() function The Pos() function identifies the first instance of a unique character and returns the number of characters from the start of a string to that instance of the character. Using date functions The three most commonly used date functions are: • ToDate: changes the data type of a value to date • CurrentDate: gives the date today • DaysBetween: calculates the number of days between two dates In this unit, you will consider the process of converting a string to a date as dates are often formatted as character type at either the database or universe level. You will use all of these date functions to create a variable named Trading Years. Using If Logic The If() function is a powerful tool available to Web Intelligence report designers. Often referred to as "If... Then... Else" logic, this function can be used in many different ways to apply custom formulas in a report. This lesson shows you how to use the If() function logic


in two ways: to group values in a variable, and to modify the way calculations behave when certain values are returned by an object. Using If() to group data In this unit, you will use the If() function to group values returned from the database into categories. Using the If() in this manner, report designers are empowered to perform the report equivalent of the Decode, Case, and If functions available to universe designers at the database level. If() can be used to group some of the values returned by an object and then to define that grouping as a new variable in the document.

Grouping values with the If() function to show higher levels of detail You can use the If() function in Web Intelligence to group values returned by an object into categories. These categories can then be used as the basis for aggregating measures at higher levels of detail. For example, the eFashion universe contains Quarter and Quantity sold objects, which allow you to analyze the quantity sold totals for each quarter. However, if your reporting requirement is to display the quantity sold measure aggregated at the half year level of detail, then the universe does not provide the objects you need to meet this requirement. By creating a Half Year variable based on the Quarter object, you can aggregate quantity sold totals for each half of the year. This data can then be presented in the same report with quantity sold totals for each quarter. Grouping values with the If() function to show categories Suppose that you need to display revenue totals in both a table and a 3D pie chart aggregated for each of the eFashion Market Types. The three Market Types are Top Performers, Average Performers, and Low Performers. Each store needs to be assigned to the appropriate category based on the following business rules:


Working with Additional Reporting Techniques In this lesson you will explore several reporting techniques, including using data tracking to quickly identify changes in report data, determining whether a character string matches a particular pattern, overrding report filters or ranking to calculate total values, displaying a running sum, and displaying drill filters. Using data tracking With Web Intelligence data tracking, you can quickly identify the data changes and focus on the most relevant data when you analyze the changes. Understanding data tracking With data tracking you can highlight the values that have changed since a previous refresh for any level of aggregation. A document with data tracking activated retrieves two microcubes -- one for the reference data set and one for the current data set. The document compares the data in the two microcubes and highlights the changes according to the formatting that you defined for the changes. Similarly, when a document contains calculations on the data set, it compares the calculations on each data set to display the changes. A document with data tracking activated contains two times more data than a document for which data tracking is not active so the data tracking document can take up to three times longer to refresh. Certain actions clear the document of the data stored in the microcubes or modify the data provider. When the document no longer contains the data, the data tracking function cannot compare the data sets and highlight the changes. Similarly, when the data provider changes, the current version of the document is not compatible with the reference version so the changed data does not display.


The actions that clear the document of the data or change the data provider include: • Drilling out of scope. • Using the query drill. • Deleting a query. • Modifying the SQL generated by a data provider. This includes modifying security rights. • Purging the document. Note: When you unintentionally purge a document, you can recuperate the data from the microcube before you save the purged document. Close the document, do not save it, and open it again. Using formula language to track data changes You can use the formula language to include calculations based on data changes. For example, you can include a calculation to show the difference between the previous value and the current value of a measure. You can also use formula language to build custom alerters for formatting data changes. display the reference data set in your report, you can use the RefValue function to create a formula or variable. This function gives the value of the reference data for the measure. When there is no reference data, the function returns null. For example, when the Revenue measure currently has the value 1000, and the reference value is 900, the formula RefValue([Revenue]) returns 900. The RefValueDate function returns the date of the reference data used for data tracking. Security for data tracking Two security options exist for the data tracking feature. Your system administrator determines the rights assigned to each user. However, when you work with different report users, you may want to know the different profiles that exist: • The right to see, but not modify the data tracking. • The right to see data tracking, and to use the interface elements for data. Creating Hyperlinks You can create hyperlinks from your documents to URLs and to other documents in Web


Intelligence XI 3.0/3.1. Working with hyperlinks in Web Intelligence documents In Web Intelligence XI 3.0/3.1, you can create hyperlinks to documents and to URLs.

About hyperlinks in Web Intelligence In your Web Intelligence documents, you can create hyperlinks to: • Other documents such as Web Intelligence documents or Crystal Reports For example, a document that shows sales results per store can display the store name as a hyperlink to another document with store details. The details can include the store floor area, location, number of employees and opening hours. • URLs or websites For example, the document that shows store details can display a hyperlink to a website that shows the promotional offers and merchandise available at the store for the current period. The website also gives access information and opening hours for the store. In the Web Intelligence Interactive panel, you can create all hyperlinks via a dialog box. In the Web Intelligence Rich Client main window and the Java Report Panel, you can create hyperlinks to: • URLs or websites via a dialog box. • Other documents via the OpenDocument command. The appendix to this course, Creating Hyperlinks with the OpenDocument Command, covers creating hyperlinks with the OpenDocument command. Understanding dimensions and details As an advanced report designer, you are in a better position to communicate your organization's reporting needs to the universe designer. You can be more effective in that role when you understand the differences between dimension objects and detail objects, as well as how the universe designer decides to define an object as a dimension or a detail. The table below describes dimensions and details and their differences. The key differences are that dimensions can:


• Be part of the scope of analysis, to enable drilling on the dimension. • Merge with an object from another data source to synchronize their respective data sources. Details cannot serve the two purposes above. So when you communicate your reporting needs to a universe designer, you want to consider what objects you want to use when defining scope of analysis for drilling, and what objects you want to use for synchronizing different data sources.

Understanding the impact of changing the object qualification When your reporting needs changing and you discover the need to change a dimension to a detail, or to change a detail to a dimension, the change can impact your reports. When your universe designer considers making such a change, discuss and plan for the possible consequences described in this section.


When a universe designer changes an object from a detail to a dimension, sometimes: • Additional objects are available in the hierarchies when you drill in the report. • More objects are available for synchronization between data sources. When a universe designer changes an object from a dimension to a detail, sometimes: • Objects disappear from the hierarchies and existing drill documents have objects missing from the scope of analysis. • Objects are no longer at the top level in the class. Instead, they appear as an associated object. The risk is that they may be associated with the wrong object. • Objects appear available for data synchronization when they may not be compatible with objects from other data sources. Reports which use the dimension object to merge data from multiple data sources no longer function properly because you cannot merge detail objects. Using OpenDocument to create a hyperlink to documents In Web Intelligence Rich Client and the Java Report Panel, you create a link to a document with a formula that uses the OpenDocument command. The command can pass detailed data to the second document, based on the prompted query filter built in the query of the linked document.

Resumen(bow320)  
Read more
Read more
Similar to
Popular now
Just for you