Top Banner
Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager, Entrinsik | 10-11-2010
40

Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Apr 01, 2015

Download

Documents

Shawna Hardin
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Calculated Columns

2010 Copyright Entrinsik, Inc.

Enhance your reports with template and script columns

PRESENTER: Andrea Dawkins | R&D Project Manager, Entrinsik | 10-11-2010

Page 2: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

2010 Copyright Entrinsik, Inc.

Page 3: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Two Kinds of Calculated Columns

Template

Script

© 2010 Entrinsik, Inc.

Page 4: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Template Columns

Other columns can be used as placeholders for the real value, like a WordMerge letter

Written with plain text and HTML

Examples:

Joining columns together (like first and last name)

Making a link to another website

In-lining pictures

© 2010 Entrinsik, Inc.

Page 5: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Script Columns

More advanced -- can do anything a Template column can do, plus calculations and conditional output.

Written with JavaScript

Examples:

Color-coding values based on a threshold

Calculating taxes and remaining balance on an order

Counting the number of days since a certain date

© 2010 Entrinsik, Inc.

Page 6: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Template Example # 1: Joining Columns

© 2010 Entrinsik, Inc.

Page 7: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Joining Columns: Drag & Drop

Drag & drop the column headers into the Expression box to get this:

${firstName} ${lastName}

Produces:

Doug Leupen

© 2010 Entrinsik, Inc.

Page 8: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Joining Columns: Mix in HTML

Insert HTML into your column to change the style:

${firstName} <b>${lastName}</b>

Produces:

Doug Leupen

© 2010 Entrinsik, Inc.

Page 9: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Remember… Don’t remove the original columns. Hide them instead.

© 2010 Entrinsik, Inc.

Page 10: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Template Example # 2: Link to a Website

© 2010 Entrinsik, Inc.

Page 11: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Link to a Website: Using the ‘a’ tag

A hyperlink tag in HTML:

<a href = “http://www.entrinsik.com”> Entrinsik</a>

Produces:

Entrinsik

© 2010 Entrinsik, Inc.

Page 12: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Link to a Website: Add in Columns

Use columns in the URL and in the text to display:

<a href = “http://linkedin.com/in/${linkedinID}”>${firstName} ${lastName}’s Profile

</a>

Produces:

Sharon Shelton's Profile

© 2010 Entrinsik, Inc.

Page 13: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Link to a Website: Choose the Window

Open every link in a new window using target = _blank:

<a href = “http://linkedin.com/in/${linkedinID}” target=“_blank">${firstName} ${lastName}’s Profile

</a>

Use target = “MyWindowName” to open links in the same window.

© 2010 Entrinsik, Inc.

Page 14: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Sorting Trick

Add this to the beginning of any

calculated column to choose sorting value:

<a name = “${columnToSortBy}” />

© 2010 Entrinsik, Inc.

Page 15: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Template Example # 3: In-line Pictures

© 2010 Entrinsik, Inc.

Page 16: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

In-line Pictures: Use the ‘img’ tag

An image tag in HTML: <img src = “http://entrinsik.com/images/logo.gif” />

Produces:

© 2010 Entrinsik, Inc.

Page 17: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

In-line Pictures: Add in Columns

Use columns in the image URL:

<img src = “http://mysite.com/products/${ID}.jpg” />

Specify the height or width:

<img src = “http://mysite.com/products/${ID}.jpg” height=100 />

<img src = “http://mysite.com/products/${ID}.jpg” width=100 />

© 2010 Entrinsik, Inc.

Page 18: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Template Example # 4: Embed a Map

© 2010 Entrinsik, Inc.

Page 19: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Embed a Map: Make the Address

Start by making a template column with an address separated by commas:

${my_street}, ${my_city}, ${my_state} ${my_zip}

© 2010 Entrinsik, Inc.

Page 20: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Embed a Map: Go to Google Maps

Grab the link for “Paste HTML to embed in a website”

Substitute the address in that text with your column variable.

© 2010 Entrinsik, Inc.

Page 21: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Embed a Map: Insert Address

The result should look something like this:

<iframe width="700" height="350" frameborder="0" scrolling="no“ src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q= ${destinationAddress}&iwloc=A&amp;output=embed"></iframe>

Make sure to set the column to Hidden and Show in row body.

© 2010 Entrinsik, Inc.

Page 22: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Embed a Map: Result

© 2010 Entrinsik, Inc.

Page 23: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Script Example # 1: Color Coding

© 2010 Entrinsik, Inc.

Page 24: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Color Coding: If Statements

Use an if statement to assign colors based on some condition.

if (condition1) { do this }

else if (condition2) { do that }

else { do the other thing }

© 2010 Entrinsik, Inc.

Page 25: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Color Coding: Setting the Threshold

Actual code using a column called probability:

if ( probability <= 10 ) {

"<div style='color:red'>" + probability + "% </div>";

}

else if ( probability >= 70 ) {

"<div style='color:green'>" + probability + "% </div>";

}

else {

probability + "%";

}

© 2010 Entrinsik, Inc.

Page 26: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Color Coding: Result

JavaScript from the previous slide produces:

© 2010 Entrinsik, Inc.

Page 27: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Avoiding null

Empty values in your script cause “null” to appear, unless you wrap your code with this:

© 2010 Entrinsik, Inc.

if ( probability != null )

{

//code here

}

Page 28: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Script Example # 2: Using Numbers

© 2010 Entrinsik, Inc.

Page 29: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Using Numbers: Calculate Balance Due

Get the balance by subtract the amount paid from the order total (both of which are columns in a report)

orderTotal – amountPaid;

Assign the column as Numeric and right-aligned.

© 2010 Entrinsik, Inc.

Page 30: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Using Numbers: Balance Due? Yes or No

Does the client have a balance due? Figure it out by combining an if statement with your calculation:

if ( orderTotal – amountPaid > 0 ) { “Yes” };else { “No”; }

Now you can group on Yes or No

© 2010 Entrinsik, Inc.

Page 31: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Using Numbers: Paying Taxes

Determine if they paid taxes or not by the state they live in:

if ( state == “NC” || state == “VA” ) {

orderTotal * 0.07;

}

else {

0;

}

© 2010 Entrinsik, Inc.

Page 32: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Script Example # 3: One Multi-value

© 2010 Entrinsik, Inc.

Page 33: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

One Multi-value: Inside an Array Multi-values appear to a Script column as an array, or a list of values

inside a single variable.

If you ever see this in your script column, you’re dealing with an array: [Ljava.lang.Object;@1e07cdbte]

Pick an item out of an array by its position in the list surrounded by square brackets: myColumn[3]

© 2010 Entrinsik, Inc.

Page 34: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

One Multi-value: Array Indexes Start counting at 0 (the first index):

© 2010 Entrinsik, Inc.

You write in… Which gives you…

orders[0] the 1st multi-value

orders[3] the 4th multi-value

orders[orders.length-1] the last multi-value

orders[orders.length] error, out of range.

Page 35: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Looping

To go through every item in an array, you’ll need to use for loops.

© 2010 Entrinsik, Inc.

for ( var i = 0; i < orders.length; i++ )

{

orderTotal[i] = orderTotal[i]*1.07;

}

Page 36: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Script Example # 4: Counting Days

© 2010 Entrinsik, Inc.

Page 37: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Counting Days: What is Today?

Java has built-in date and time functions that do these calculations for us, and we can access them through the Script column

Today’s date in Java: var today = new Date();

Date in milliseconds (since 1970): myDate.getTime();

© 2010 Entrinsik, Inc.

Page 38: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Counting Days: Subtracting Milliseconds

To count the days past since a date:

var today = new Date();

var diff = today.getTime() - myDate.getTime();

diff / (1000 * 60 * 60 * 24);

The variable diff gives the millisecond difference. Number of days: divide by (1000 * 60 * 60 * 24)

Number of weeks: divide by (1000 * 60 * 60 * 24 * 7)

Number of years: divide by (1000 * 60 * 60 * 24 * 7 * 52)

© 2010 Entrinsik, Inc.

Page 39: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Resources

HTML: http://www.w3schools.com/html/html_examples.asp

JavaScript: http://www.w3schools.com/js/js_examples.asp

CSS (styles): http://www.w3schools.com/css/css_examples.asp

Reports from today: http://trial.entrinsik.com:8080

YouTube examples: http://www.youtube.com/entrinsikinc

More examples: http://delivery.entrinsik.com/portal/index.php?board=6.0

© 2010 Entrinsik, Inc.

Page 40: Calculated Columns 2010 Copyright Entrinsik, Inc. Enhance your reports with template and script columns PRESENTER: Andrea Dawkins | R&D Project Manager,

Thank you! Any questions?

© 2010 Entrinsik, Inc.