chapter 5 files/folders needed: \chapter5\samples \chapter5\labs

13
Custom Expressions Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Upload: helena-fowler

Post on 12-Jan-2016

238 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Custom Expressions Chapter 5

Files/Folders needed:\Chapter5\Samples

\Chapter5\Labs

Page 2: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

• Understanding Expressions• Defining Expressions• Working with Report Variables• Enhance Formatting by Using Expressions• Understanding Lookup, LookupSet, and

Multilookup Functions• Expression Samples

In this Chapter

Page 3: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Many uses◦ Create aggregates◦ Compute complex values◦ Dynamically hide and show values◦ Format based on a value

Simple expressions=Fields!Product.Value

Expression with multiple functions=IIf((RowNumber(Nothing) Mod 2)=0, "LightGrey“

, "LightSteelBlue") 

Understanding Expressions

Page 4: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Expressions written in Visual Basic (with some unique rules)

Many code parts are case sensitive Double quotes (" ") surround string values

◦ Be careful of “Smart Quotes” when copying from MS Word

No underscore (_) for line continuation◦ Use a hard return alone to make code more

readable Data type conversions and functions use

standard VB naming

VB Basics for Expressions

Page 5: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Accessed through Expression menu options, or the function button.

Type code directly in the box, or double-click a value or item

Red wavy underlines may indicate errors◦ Some errors won’t be obvious

until you preview the report

Defining Expressions

Page 6: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Options change based on Category field selected

The Expression Dialog Box

Page 7: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Added through Report Properties dialog box Accessed from the Report menu Evaluated once

per report Used anywhere in

the report

Working with Report Variables

Page 8: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Returns data from a second dataset Each requires 4 input parameters

◦ The source key or names to lookup◦ The destination key or name to match on◦ The expression to be returned◦ The destination dataset name

Lookup, LookupSet, and Multilookup Functions

Page 9: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Lookup

=Lookup(Fields!BusinessEntityID.Value , Fields!SalesPersonID.Value, Fields!TotalSales.Value , "SalesPersonTotalSales")

Returns one value for each source key of name◦ For example – returns an account description

located in an Excel spreadsheet to match the account code listed in the dataset that is bound to a table.

Page 10: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Returns all values that match the source key or name

Passes a set (or array) back to the expression◦ For example, locate in a different dataset, all

order dates for a particular customer, and list them as a single value in a new column.

LookupSet

=Join(LookupSet(Fields!BusinessEntityID.Value , Fields!SalesPersonID.Value ,Fields!SalesOrderID.Value , "SalesOrders“ ) , “, “ & vbCrLf)

Page 11: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Handles many-to-many relationships between the two datasets

The source may be an array that needs to be split◦ Example – Look up a list of countries where each

employee has placed orders. The list of order numbers associated with the employee must be split and then an array of countries will be returned.

The source may be a multi-valued parameter

Multilookup

Page 12: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Derived columns based on an expression◦ Add a weight range title to a new column◦ Add a member level based on early purchases

Format based on an expression◦ Change the background color of every other row◦ Change the font color for rows with high sales

Expression Samples

Page 13: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs

Exercise 1: Using Expressions to Work With Dates

Exercise 2: Using Expressions to Manipulate Data

Chapter 5 Lab