08.08.2017 Views

designer

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

164 Chapter 5 Working with Data Views<br />

In this exercise, you create a formula column labeled Sale Price. The sale price is 25 percent<br />

of the unit price for those product lines in the sale. If a product line has 10 or fewer<br />

items in stock, that product line cannot be in the sale. The sale price should be formatted<br />

in dollars, with two decimal places.<br />

SET UP Using SharePoint Designer, open the site you used in the previous exercise if<br />

it is not already open, and then open Stock.aspx in edit mode with the Furniture Price<br />

List DFWP selected.<br />

Add/Remove<br />

Columns<br />

1. On the Data View Tools, Options tab, click Add/Remove Columns in the Fields<br />

group.<br />

The Edit dialog box opens.<br />

2. In the Available fields list, scroll down, click Add Formula Column, and then click<br />

Add.<br />

The XPath Expression Builder dialog box opens.<br />

3. In the Select a field to insert list, double-click Unit_x0020_Price.. Be sure you<br />

choose the field that ends in a dot.<br />

@Unit_x0020_Price. is displayed in the Edit the XPath Expression box.<br />

4. In the Exit the XPath expression box, place the insertion point to the right of Price.,<br />

and then type * (1 - ((@Sale = 'Yes') and (@In_x0020_Stock. >= 10))* 0.25).<br />

Tip The practice file SPDSBSC05.xsl.txt contains this expression if you want to copy and<br />

paste the expression into the XPath Expression Builder dialog box.<br />

The Preview box displays the result of the expression.<br />

5. Click OK twice. The Insert Formula and Edit Columns dialog boxes close.<br />

A new column is added to the DFWP. The column label is the expression you created<br />

in step 4. Only those product lines in the sale have a sales price less than the<br />

unit price.<br />

6. In the column heading, click @Unit. Then click the th.ms-vh label that appears,<br />

and type Sale Price.<br />

7. In the Sale Price column, click 15, and then on the Options tab, click Formula.<br />

The Insert Formula dialog box opens and displays the expression you created in<br />

step 4. If the expression is not shown, close the Insert Formula dialog box and repeat<br />

step 7.<br />

8. In the Select a function category, select Math / Number. In the Select a function<br />

to insert box, click format-number.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!