chapter 5 files/folders needed: \chapter5\samples \chapter5\labs
TRANSCRIPT
![Page 1: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/1.jpg)
Custom Expressions Chapter 5
Files/Folders needed:\Chapter5\Samples
\Chapter5\Labs
![Page 2: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/2.jpg)
• 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](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/3.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/4.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/5.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/6.jpg)
Options change based on Category field selected
The Expression Dialog Box
![Page 7: Chapter 5 Files/Folders needed: \Chapter5\Samples \Chapter5\Labs](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/7.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/8.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/9.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/10.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/11.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/12.jpg)
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](https://reader036.vdocuments.net/reader036/viewer/2022082322/56649ea05503460f94ba2d52/html5/thumbnails/13.jpg)
Exercise 1: Using Expressions to Work With Dates
Exercise 2: Using Expressions to Manipulate Data
Chapter 5 Lab