Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

SQL Server 2008 Reporting Services : Developing Expressions - Using Aggregate Functions (part 2) - Using an Aggregate Function in a Data Region

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
7/6/2011 11:24:53 AM

Using an Aggregate Function in a Data Region

The main difference between using an aggregate function in a freestanding text box and using one in a data region is the Scope argument. Whereas this argument is required in a freestanding text box, you can omit the Scope argument in a data region if Reporting Services can infer the scope correctly. An exception to this rule is the RunningValue function, which not only requires you to specify scope but also requires you to specify an aggregate function to use to accumulate values.

To better understand how you might use the RunningValue function, consider a request from a business user to facilitate comparisons of product mixes across reseller business types. More specifically, the business user wants to see which products contribute most to sales for each reseller business type. To support this analysis, your report must show the products grouped by reseller business type. You must calculate the cumulative sales for each product within the group and the cumulative percentage of total sales for the group. When the products are sorted in descending order, the user can see easily which products collectively contribute to a target percentage of sales, such as the top 20 percent of sales or the top 50 percent of sales.

In this procedure, you use the RunningValue function to compute the cumulative sales and percentage of cumulative sales by product for each business type.

Use the RunningValue function in a tablix

1.
Click the Design tab, click the tablix, right-click the Sales Amount column handle, select Insert Column, and select Right to add a new column.

2.
In the new column, in the detail row (to the right of [SalesAmount]), right-click the text box, and select Expression.

3.
In the Set Expression For: Value box, create the following expression:

=RunningValue(Fields!SalesAmount.Value, Sum, "BusinessType")

Important

Be careful to match the case exactly when specifying the Scope argument in an aggregate function. Note that you must enclose the scope name in double quotes. When using the RunningValue function, be sure to include the aggregate function without quotes.

4.
Click OK to close the Expression dialog box.

5.
In the Properties window, in the Name text box, type CumulativeSales.

6.
In the header text box above the new expression, click twice to insert the cursor inside the text box, and then type Cumulative Sales.

7.
Click the column handle of the new column, and then, in the Properties window, in the Format text box, type C0.

8.
Right-click the Cumulative Sales column handle, select Insert Column, and select Right to add a new column.

9.
In the new column, in the detail row (to the right of <<Expr>>), right-click the text box, and select Expression.

10.
In the Expression dialog box, create the following expression:

=ReportItems!CumulativeSales.Value/ReportItems!BusinessTypeTotal.Value

This expression computes the percentage of sales for the cumulative sales value of the current record.

11.
Click OK to close the Expression dialog box.

12.
In the header text box above the new expression, click twice to insert the cursor inside the text box, and type Cumulative Sales Pct.

13.
Click the Cumulative Sales Pct column handle, and then, in the Properties window, in the Format text box, type P0.

14.
Save and then preview the report.

15.
Click the Next Page button on the Preview toolbar to view the second page and confirm the cumulative sales value resets to 0 when the next business type instance begins, as shown here.



Currently, because the product data is not sorted, products are listed in the order that the records are returned from the database. When working with cumulative sales data, you can sort the data in descending order by sales amount to easily see which set of products represent a particular percentage of sales.

16.
Click the Design tab, and then, in the Row Groups pane, right-click (Details), and click Group Properties.

17.
In the Group Properties dialog box, click Sorting.

18.
Click Add, and then, in the Sort By drop-down list, select [SalesAmount].

Notice the Expression button to the right of the Sort By drop-down list. Instead of sorting by a field in the dataset, you can define an expression to sort data.

19.
In the Order drop-down list, select Z To A to sort in descending order, and click OK.

20.
Save and then preview the report, as shown here.



In the report, you can now see that in specialty bike shops in France, four products represent more than 50 percent of all sales.
Other -----------------
- Microsoft Dynamics AX 2009 : Enterprise Portal and Web Parts & Reporting Framework
- Microsoft Dynamics AX 2009 : Application Model Layering System & Application Frameworks
- Microsoft Dynamics AX 2009 : Application Development and Runtime Configurations & Architecture of Dynamics AX
- Microsoft PowerPoint 2010 : Expanding PowerPoint Functionality - Inserting ActiveX Controls & Using ActiveX Controls
- Microsoft PowerPoint 2010 : Saving a Presentation with Macros & Opening a Presentation with Macros
- SQL Server 2008 : Managing Backups - Backup Types
- SQL Server 2008 : Managing Backups - Recovery Models & Backup Architecture
- Microsoft Dynamics CRM 2011 : Closing an Opportunity & Reopening an Opportunity
- Microsoft Dynamics CRM 2011 : Using Opportunities to Forecast Potential Sales
- Integrating Dynamics NAV and the Microsoft Office system (part 3) - Using extensibility with NAV 2009 SP1
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server