inquiry formulas - deltek | axium... a string function. you will also learn how to use ... to” or...

40
Inquiry Formulas student guide

Upload: hoangtu

Post on 21-Mar-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Inquiry Formulas student guide

Page 2: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

NOTICE This documentation and the Axium software programs may only be used in accordance with the accompanying Ajera License Agreement.

You may not use, copy, modify, or transfer the Axium programs or this documentation except as expressly provided in the Ajera License Agreement.

AXIUM™ and the Axium software logo as it appears in this manual are registered Marks of XTS Software Corporation dba Axium.

Microsoft and Windows are registered trademarks of Microsoft Corporation in the United States and/or other countries.

All other company, product, or brand names mentioned herein, may be the trademarks of their respective owners.

© 2007, 2010-11 XTS Software Corporation dba Axium. All rights reserved. Copyright includes accompanying software and windows generated by the software.

Page 3: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Inquiry Formulas 3

Contents Goals of this session ................................................................................................. 4 

What you will learn ................................................................................................... 4 What you will not learn ............................................................................................. 4 

About the Ajera database .......................................................................................... 5 The Inquiry interface ................................................................................................. 5 

Inquiry formulas ......................................................................................................... 6 Basic formulas .......................................................................................................... 6 Advanced formulas ................................................................................................... 6 Advanced custom formulas ...................................................................................... 7 

Briefly about SQL ....................................................................................................... 8 Useful SQL elements ............................................................................................... 8 

Producing a project detail report by date range ................................................... 10 Scenario ................................................................................................................. 10 Overview ................................................................................................................. 10 Creating the Project Detail History inquiry ............................................................. 11 Creating the Project Totals and History inquiry ...................................................... 12 Changing the Project Totals and History inquiry .................................................... 12 Changing the Project Detail History inquiry ............................................................ 14 

Changing the project detail report ......................................................................... 20 Scenario ................................................................................................................. 20 Overview ................................................................................................................. 20 Reformatting the Project Detail History inquiry ...................................................... 21 Searching for a SQL function ................................................................................. 21 Creating a Month column using the SQL function formula .................................... 24 Grouping and subtotaling information by columns ................................................. 26 

Producing a payroll service input worksheet ....................................................... 27 Scenario ................................................................................................................. 27 Overview ................................................................................................................. 27 Creating the Payroll Input Sheet inquiry ................................................................. 28 Changing the Payroll Input Sheet inquiry ............................................................... 29 Creating a Regular time column using a SQL function formula ............................. 29 Creating an Overtime column using a SQL function formula ................................. 31 Creating a Vacation column using a SQL function formula ................................... 32 Creating a Sick time column using a SQL function formula ................................... 33 Creating a Holiday column using a SQL function formula ..................................... 34 Verifying the formula columns and changing the inquiry ....................................... 35 

Appendix A: Advanced custom formulas ............................................................. 37 Use for static information ........................................................................................ 37 Common SQL statements and clauses .................................................................. 38 

Page 4: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

4 Inquiry Formulas

Goals of this session In this intermediate-level session of Inquiry, you will receive a brief introduction to Structured Query Language (SQL) functions and learn about the different kinds of Inquiry formulas.

The session will then ease you into using formulas by stepping through building two complete sample inquiries. These inquiries illustrate how to use the SQL functions CASE and DATENAME to filter amount columns using field criteria in a formula and to sort through a data field using a string function. You will also learn how to use custom linking and grouping for subtotals.

What you will learn In this session, you will learn how to:

Use a CASE function in a simple-when form to evaluate one value and indicate whether a transaction is labor, expense, or consultant.

Use a DATENAME function to extract the month from transaction dates.

Change a CASE function from a simple-when form to a searched-when form to evaluate multiple values and indicate whether time entered is Regular, Overtime, Vacation, Sick, or Holiday.

Note: This session uses CASE and DATENAME only as examples. There are many more SQL functions that you can use in Inquiry.

What you will not learn In this session, you will not learn:

SQL programming

Structure of the Ajera database

Axium recommends that you request the services of a SQL consultant or an Ajera consultant, respectively, if you are interested in learning those topics.

Page 5: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

About the Ajera database

Inquiry Formulas 5

About the Ajera database The Ajera database is written in Structured Query Language. SQL is a standard programming language designed for querying and modifying data and for managing databases.

The Ajera database consists of interrelated tables, each one containing a specific kind of data, such as employee or project information. Each column in a table describes one characteristic of the table data. For example, a table about employee information contains columns for employee first name and employee last name.

Each row in a table is a database record or table entry. In the employee table, for example, a row is an entry for an individual employee. Ajera automatically assigns each row a number. That number is a key field, a unique identifier of the database record. You cannot change key fields.

Ajera uses key fields to “link to” or access information between database tables. For instance, when you enter information about a project in the Project Command Center, Ajera automatically creates a draft client invoice that uses a key field to identify the project.

The Inquiry interface Inquiry accesses and retrieves information from the Ajera database and displays it in a table. Like the database, each row in the Inquiry table corresponds to a database record, and each column corresponds to an information field that makes up that database record.

This row in the Employee inquiry represents a database record for Pat D. Hill.

Employee type is one piece of information that makes up the database record.

Page 6: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Inquiry formulas

6 Inquiry Formulas

Inquiry formulas When you create a new inquiry column, you can either add it from the predefined list of columns, or create your own column by defining a formula for it.

When you create a formula, you can use other existing formulas in the inquiry. These appear in the Available Columns area of the Formula Editor. The Available Columns area also contains the Current User Key, which allows you to display inquiry data pertaining only to the user.

You can often write the formula you need by entering simple mathematical equations, which are called basic formulas.

To enter more complicated formulas, which are called advanced or advanced custom formulas, you must either understand how to use SQL commands or request the services of an Ajera consultant.

Axium supports basic and advanced formulas; it does not support advanced custom formulas.

Basic formulas You can write many different inquiry formulas using basic mathematical operators and no SQL knowledge. These formulas create new columns by specifying mathematical operations between columns that already exist in the inquiry.

For example, here are formulas for two new columns on the Project inquiry:

[Billed]-[Cost]

([Billed]+[WIP])-[Cost]

Advanced formulas When you write an advanced formula, you create a new column by defining relationships between columns that already exist in the inquiry. To view the predefined columns available in a specific inquiry, select Help > Contents > Inquiries > Standard inquiries and select that inquiry topic.

To create advanced formulas, you do not need to know the structure of the Ajera database. You do, however, need to know how to use SQL functions. You use these functions to filter the data in the existing columns so that the new column displays exactly the information you want.

Some commonly used functions include:

LEFT

RIGHT

INSTRING

DATEDIFF

DATEADD

MONTH

UPPERCASE

Page 7: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Inquiry formulas

Inquiry Formulas 7

Following is an example of an advanced formula for the Transaction - All inquiry:

CASE [Activity Type] WHEN 'Labor' THEN [Employee]

WHEN 'Expense' THEN [Activity]

WHEN 'Consultant' THEN [Vendor]

WHEN 'None' THEN 'Invoice Adjustment'

END

The formula uses the SQL function, CASE, to populate the new column as follows:

If the Activity Type is Then the formula returns

Labor the employee

Expense the activity

Consultant the vendor

None the text “Invoice Adjustment”

Advanced custom formulas Advanced custom formulas are not based on a relationship between existing columns in an inquiry. To write this type of formula, you must know the structure of the Ajera database and how to use SQL functions.

For more information about these formulas, see Appendix A on page 37.

Axium recommends that you request the services of an Ajera consultant if you are interested in using these formulas.

Page 8: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Briefly about SQL

8 Inquiry Formulas

Briefly about SQL SQL ignores insignificant white spaces, which allows you to format formulas for readability. Also, SQL is not case-sensitive, and its syntax allows you to insert line breaks wherever you want.

SQL comes in many different versions. Ajera uses Microsoft SQL Server, which is based on Transact-SQL. To learn more, visit the Microsoft website.

Useful SQL elements The following SQL functions and expressions are useful in getting the data you want with Inquiry. Axium recommends using them in advanced formulas.

CASE

Use the CASE function to evaluate a list of search conditions and return one of many possible results.

CASE comes in two formats:

Simple-when: Compares an expression to a set of simple expressions to determine the result.

Searched-when: Evaluates a set of Boolean expressions to determine the result.

Syntax

simple-when CASE input_expression

WHEN when_expression THEN result_expression [ . . . n]

[ ELSE else_result_expression ]

END

searched-when CASE

WHEN Boolean_expression THEN result_expression [ . . . n]

[ ELSE else_result_expression ]

END

Page 9: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Briefly about SQL

Inquiry Formulas 9

DATENAME

Use the DATENAME function to retrieve part of a specified date.

Syntax

DATENAME (datepart, date)

AND and OR

You can also use the AND and OR expressions to join two or more Boolean expressions. The expressions limit the data returned by the formula.

The AND expression returns a result when both conditions are met. The OR expressions returns a result when at least one of the conditions is met.

If a formula contains both AND and OR, the AND condition is automatically evaluated first. You can change the order by using parentheses.

Syntax

AND <Boolean_expression> AND <Boolean_expression>

OR <Boolean_expression> OR <Boolean_expression>

Page 10: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a project detail report by date range

10 Inquiry Formulas

Producing a project detail report by date range This first exercise introduces you to the simple-when format of CASE. CASE is similar to an IF statement, and is useful for categorizing data in inquiry formula columns.

CASE compares a source value against a test value and returns the requested result when a match is found. In this exercise, the source value is an Ajera data field, and the test value is what you are looking for in the data field. The source and test values must be the same data types.

If no match is found, CASE will return an ELSE result or a NULL value, depending on what is specified. CASE functions always end with the word END.

Scenario In this scenario, your principal asks you for a project history with detail for a range of dates. Your principal wants the history to include only time and expense entries and to display the detail by the appropriate description for labor, expense, or consultant. Your goal is to create a custom inquiry that produces this information.

Overview To create the new inquiry, you will:

Create a custom inquiry named Project Detail History.

Create a custom inquiry named Project Totals and History.

Change the Project Totals and History inquiry.

Change the Project Detail History inquiry by using a simple-when CASE function.

Page 11: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a project detail report by date range

Inquiry Formulas 11

Creating the Project Detail History inquiry First, create a custom inquiry based on the Transaction - All inquiry.

1. From the Inquiry menu, click Transaction > Transaction – All.

Note: The red text at the top of the inquiry discourages using it as a stand-alone inquiry.

2. In the Inquiry toolbar, click the Save As button and name this custom inquiry Project Detail History.

3. Click the close button in the top right of the inquiry.

Page 12: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a project detail report by date range

12 Inquiry Formulas

Creating the Project Totals and History inquiry Now, create a custom inquiry based on the standard Project inquiry.

1. From the Inquiry menu, click Project > Project.

2. In the Inquiry toolbar, click the Save As button and name this custom inquiry Project Totals and History.

Changing the Project Totals and History inquiry Change the Project Totals and History inquiry so that it displays only the information you want, and then link it to the Project Detail History inquiry.

Links allow you to filter the information displayed in an inquiry. Add a date range so you can view data in the Project Detail History inquiry for a specific time period.

Removing unneeded columns

1. Remove unneeded columns by right-clicking their column headings and clicking Remove column.

In this exercise, leave only the following columns:

Project ID

Project Description

Client

Total Contract Amount

Spent

2. In the Inquiry toolbar, click the Save button.

Page 13: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a project detail report by date range

Inquiry Formulas 13

Adding a link

1. Right-click the Spent column heading and click Properties.

2. On the Link tab, select Project Detail History from the Link list.

3. On the General tab, select Range prompt from the Date Range list.

4. Click OK to return to the Project Totals and History inquiry.

Page 14: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a project detail report by date range

14 Inquiry Formulas

Changing the Project Detail History inquiry Change the Project Detail History inquiry so that it displays only the information you want, sort it so the most recent date appears first, and create columns by which to group and subtotal the data. Use SQL functions to create the formulas for the columns.

Removing unneeded columns and sorting by date

1. Click the blue Spent amount for any project in the Project Totals and History inquiry, to return to the Project Detail History inquiry.

2. In the Save window that appears, click the Yes button. The Project Detail History inquiry appears.

3. Remove unneeded columns from the Project Detail History inquiry by right-clicking their column headings and clicking Remove column.

In this exercise, leave only the following columns:

Date

Project ID & Description

Phase ID & Description

Units/Hours

Spent Amount

4. In the Inquiry toolbar, click the Save button.

5. Click the Show All Rows button if it appears in the toolbar, so that you can see all the data.

Note: The Show All Rows button appears in the toolbar only if the project has more than 2,500 rows of detail. In addition, the inquiry title will include this message:

<Inquiry title> (first 2500 rows; click “Show All Rows” to show all)

Page 15: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a project detail report by date range

Inquiry Formulas 15

6. Right-click the Date column heading and click Sort descending.

7. To add notes from timesheets and expense entries to the inquiry:

Right-click the Spent Amount column heading and click Add a column to the right.

On the General tab, select Notes from the Column list and type 3.00 in the Width field to make it wide enough for lengthy text.

Click OK to return to the inquiry.

Creating a description formula for transaction type

In the Project Detail History inquiry, you will use a SQL function to create a description formula to display employee name for labor transactions, activity for expense transactions, and vendor name for consultant transactions. Group and subtotal by this information.

1. Right-click the Date column heading and click Add column to the left.

2. On the General tab:

Select Formula in the Column list.

Type Detail Description in the Heading field.

Click the browse button for the Formula field, to open the Formula Editor window.

To create the Detail Description formula, you need to use a CASE function, which is similar to using an IF statement.

To accomplish this, you will use the sample advanced formula in Help, which provides the exact detail description you want and requires no modification.

Note: If you need a simple-when CASE formula in the future, you can try copying and pasting the sample formula in Help, and then changing it to meet your criteria.

3. In the Formula Editor window, click the Help button.

4. On the Index tab, type formula in the keyword field, and double-click creating advanced.

Page 16: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a project detail report by date range

16 Inquiry Formulas

5. Highlight the sample advanced CASE formula in the Help file and copy it.

6. Paste the formula into the Formula field of the Formula Editor window.

7. Click the close button in the top right of the Help window.

8. Click the Verify button at the bottom of the Formula Editor window.

9. In the Formula verification window that appears, click OK.

10. Click OK in the Formula Editor window.

11. On the General tab, change the Width field to 2.00 in the Width field to make it wide enough for lengthy text.

12. Click OK on the General tab to view the new Detail Description column in the Project Detail History inquiry.

Page 17: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a project detail report by date range

Inquiry Formulas 17

Grouping and subtotaling information by columns

Use the existing project and phase columns and the new Detail Description column to group and subtotal the information in the Project Detail History inquiry.

1. Right-click the Project ID & Description column heading and click Group expanded to group the information by this column.

2. Right-click the Phase ID & Description column heading and click Group expanded to group the phase group within the project group.

3. Right-click the Detail Description column heading and click Group expanded to group the detail group within the phase group.

You now have subtotals for phase and for employee, activity, or vendor.

4. In the Inquiry toolbar, click the Back button to return to the Project Totals and History inquiry.

5. In the Save window that appears, click the Yes button.

Page 18: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a project detail report by date range

18 Inquiry Formulas

6. The Project Totals and History inquiry appears, displaying the blue All Dates link at the top.

7. Click the blue All Dates, which opens the Date Range window.

8. Select a date range, and click OK.

9. In the inquiry, click an amount in the Spent column to return to the Project Detail History inquiry.

10. In the Save window that appears, click the Yes button.

Page 19: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a project detail report by date range

Inquiry Formulas 19

11. The Project Detail History inquiry appears, showing the detail only for the selected date range.

12. Click the close button in the top right of the inquiry.

Page 20: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Changing the project detail report

20 Inquiry Formulas

Changing the project detail report This second exercise introduces you to the DATENAME function. This function allows you to extract the month part from the date, which is useful if you want to group data by month, not by date. This exercise also shows you how to find a SQL function on the Microsoft website.

Scenario In this scenario, your principal is pleased with the Project Detail History inquiry, but would like it grouped and subtotaled by month so that it is easier to read. Your goal is to change the inquiry so that it displays the information in this way.

Overview To change the Project Detail History inquiry, you will:

Reformat the inquiry.

Search for a SQL function that meets your needs.

Create a column using a DATENAME function.

Group and subtotal the information by columns.

Page 21: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Changing the project detail report

Inquiry Formulas 21

Reformatting the Project Detail History inquiry 1. Re-open the Project Totals and History inquiry to make additional changes.

2. In the inquiry, click an amount in the Spent column to return to the Project Detail History inquiry.

3. Right-click the Project ID & Description group and click Ungroup all.

4. Notice that because the Project Detail History inquiry displays detail for only one project at a time, the Project ID & Description column is unneeded.

5. Right-click the Project ID & Description column heading and click Remove column.

Searching for a SQL function 1. To add a column that allows you to group the inquiry by month, not by date,

you need a SQL function that will extract the month part from the date data. Unlike the preceding exercise, this is not a simple CASE function, which you can copy and paste from Help.

Instead, you need to search the Internet for SQL functions. This exercise uses the Google browser: For the search type in SQL functions.

Page 22: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Changing the project detail report

22 Inquiry Formulas

Note: This session describes only one way to search for SQL functions. You can find valuable information about SQL programming on websites and in resources that are not discussed in this session.

2. Click the Built-in Functions (Transact-SQL) link for the Microsoft website.

3. Scroll down to Scalar Functions and click Date and Time Data Types and Functions.

Page 23: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Changing the project detail report

Inquiry Formulas 23

4. Click Functions That Get Date and Time Parts.

5. The DATENAME function is what you want. It will look at the transaction date and extract the name of the month, which will allow you to group and subtotal by month.

Click DATENAME to review its syntax.

Note: You can use the DATENAME function to get date totals for any period using any database date column.

Page 24: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Changing the project detail report

24 Inquiry Formulas

6. Highlight and copy the syntax for DATENAME.

Note: Later, you will change this formula in Inquiry’s Formula Editor, replacing datepart with mm and date with [Date].

Creating a Month column using the SQL function formula

1. In the Project Detail History inquiry, right-click the Date column heading and click Add column to the left.

2. On the General tab:

Select Formula from the Column list.

Type Month in the Heading field.

Click the browse button for the Formula field, to open the Formula Editor window.

3. Select the Show non-numeric columns check box so that the Date column is available for selection.

Page 25: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Changing the project detail report

Inquiry Formulas 25

4. Paste the SQL formula into the Formula field of the Formula Editor window and change it:

Change datepart to mm.

Highlight date in the formula and click Date in the Available Columns list.

5. Click the Verify button.

6. In the Formula verification window that appears, click OK.

7. Click OK in the Formula Editor window and the General tab to return to the inquiry, which displays the new Month column.

Page 26: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Changing the project detail report

26 Inquiry Formulas

Grouping and subtotaling information by columns

1. Right-click the Month column heading and click Group expanded.

2. Right-click the Phase ID & Description column heading and click Group expanded.

3. Right-click the Detail Description column heading and click Group expanded.

4. The Project Detail History inquiry now displays project to date with monthly subtotals.

5. In the Inquiry toolbar, click the Save button.

6. Click the close button in the top right of the inquiry.

Page 27: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a payroll service input worksheet

Inquiry Formulas 27

Producing a payroll service input worksheet This third exercise shows you how to change a simple-when CASE function into a searched-when CASE function. The searched-when format returns different results based on what is in the source field. It is useful when you are comparing more than one source value against a test value.

Scenario In this scenario, your principal wants you to create a report for your firm’s payroll service that lists total employee hours from timesheets.

Your firm submits total hours from timesheets broken out into Regular, Overtime, Vacation, Sick, and Holiday for the pay period. The timesheets are entered weekly, and payroll is run twice a month.

Your goal is to create a custom inquiry that makes the process of preparing these hours for the payroll service quick and easy. To do this, you will use SQL functions to filter the predefined column for Units/Hours in the Transaction – Labor inquiry and add columns for the different types of hours.

Overview To create the new inquiry, you will:

Create a custom inquiry named Payroll Input Sheet.

Change the Payroll Input Sheet inquiry.

Use search-when CASE functions to create columns that display:

o Regular time

o Overtime

o Vacation time

o Sick time

o Holiday time

Verify the formula columns and change the inquiry again.

Page 28: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a payroll service input worksheet

28 Inquiry Formulas

Creating the Payroll Input Sheet inquiry 1. From the Inquiry menu, click Transaction > Transaction – Labor.

Note: The red text at the top of the inquiry discourages using it as a stand-alone inquiry.

2. In the Inquiry toolbar, click the Save As button and name this custom inquiry Payroll Input Sheet.

3. In the Inquiry toolbar, click the Properties button.

4. On the Conditions tab, set the following conditions to eliminate rows that are not from timesheets and are not within the pay period you are reporting to the payroll service:

Transaction Type — equals sign (=) — Entry.

Date — greater-than-or-equal-to sign (>=) — <first day of pay period> (for example, February 1, 2009).

Date — less-than-or-equal-to sign (<=) — <last day of pay period> (for example, February 28, 2009).

5. On the General tab, type a description and instructions in the Instructional Text field. For example: This input sheet provides timesheet hours for a range of dates broken out by regular, overtime, vacation, sick, and holiday. Enter the beginning and ending pay period dates on the Conditions tab.

6. Click OK.

Page 29: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a payroll service input worksheet

Inquiry Formulas 29

Changing the Payroll Input Sheet inquiry 1. Remove unneeded columns by right-clicking their column headings and

clicking Remove column.

In this exercise, leave only the following columns:

Transaction Type

Date

Activity

Employee

Hours Type

Units/Hours

Note: After using the Hours Type and Activity columns to verify the formula columns later in this session, you will remove them from the inquiry.

2. In the Inquiry toolbar, click the Save button.

3. Right-click the Employee column heading and click Sort ascending.

4. To rename the Units/Hours column:

Right-click the column heading and click Properties.

On the General tab, type Total Hours in the Heading field and click OK.

Creating a Regular time column using a SQL function formula

1. Right-click the Total Hours column heading and click Add column to the left.

2. On the General tab:

Select Formula from the Column list.

Type Regular in the Heading field.

Click the browse button for the Formula field, to open the Formula Editor window.

Page 30: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a payroll service input worksheet

30 Inquiry Formulas

3. Select the Show non-numeric columns check box.

4. In the Formula field of the Formula Editor window, paste the sample advanced formula for CASE from Help (which you used in the first exercise). However, because you have more than one value for the CASE statement to evaluate, you need to change the Help sample syntax from simple-when form to searched-when form:

Cut the first instance of WHEN and paste it after CASE.

Highlight [Activity Type] and click Hours Type in the Available Columns list and type an equals sign (=).

Change ‘Labor’ to ‘Regular’, type AND, and click Activity in the Available Columns list.

Type NOT IN(‘Vacation’, ‘Sick’, ‘Holiday’) THEN and click Units/Hours in the Available Columns list.

Delete the remaining text.

Type END.

This formula will result in the column displaying only hours that have an Hours Type of Regular and that do not have an Activity of Vacation, Sick, or Holiday.

5. Click the Verify button.

6. In the Formula verification window that appears, click OK.

Page 31: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a payroll service input worksheet

Inquiry Formulas 31

7. Highlight the verified formula and copy it; you will use this formula to create columns for overtime and vacation time.

8. Click OK in the Formula Editor window and the General tab to view the new Regular column in the inquiry. Scroll through the data and notice that the entries without any hours listed in the Regular column are those that have an Activity of Vacation, Holiday, or Sick, or those that have an Hours Type that is not Regular.

Creating an Overtime column using a SQL function formula

1. Right-click the Total Hours column heading and click Add column to the left.

2. On the General tab:

Select Formula in the Column list.

Type Overtime in the Heading field.

Click the browse button for the Formula field, to open the Formula Editor window.

3. In the Formula field of the Formula Editor window, paste the formula you used to create the Regular column, and change ‘Regular’ to ‘Premium 1’. (Premium 1 is the Hours Type description for overtime.)

This formula will result in the column displaying only hours that have an Hours Type of Premium 1 and that do not have an Activity of Vacation, Sick, or Holiday.

Page 32: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a payroll service input worksheet

32 Inquiry Formulas

4. Click OK in the Formula Editor window and the General tab to view the new Overtime column in the inquiry and scroll through the data.

Creating a Vacation column using a SQL function formula

1. Right-click the Total Hours column heading and click Add column to the left.

2. On the General tab:

Select Formula in the Column list.

Type Vacation in the Heading field.

Click the browse button for the Formula field, to open the Formula Editor window.

3. In the Formula field of the Formula Editor window, paste the formula used to create Regular time and change it:

Delete [Hours Type]= ’Regular’ AND

Change NOT IN to an equals sign (=)

Change (‘Vacation’, ‘Sick’, ‘Holiday’) to ‘Vacation’

This formula will result in the column displaying only hours that have an Activity of Vacation.

4. Click the Verify button.

Page 33: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a payroll service input worksheet

Inquiry Formulas 33

5. In the Formula verification window that appears, click OK.

6. Highlight the verified formula and copy it; you will use this formula to create columns for sick time and holiday time.

7. Click OK in the Formula Editor window and the General tab to view the new Vacation column in the inquiry and scroll through the data.

Creating a Sick time column using a SQL function formula

1. Right-click the Total Hours column heading and click Add column to the left.

2. On the General tab:

Select Formula in the Column list.

Type Sick in the Heading field.

3. Click the browse button for the Formula field, to open the Formula Editor window.

4. In the Formula field of the Formula Editor window, paste the formula you used to create the Vacation column and change ‘Vacation’ to ‘Sick’.

This formula will result in the column displaying only hours that have an Activity of Sick.

5. Click OK in the Formula Editor window and the General tab to view the new Sick column in the inquiry and scroll through the data.

Page 34: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a payroll service input worksheet

34 Inquiry Formulas

Creating a Holiday column using a SQL function formula

1. Right-click the Total Hours column heading and click Add column to the left.

2. On the General tab:

Select Formula in the Column list.

Type Holiday in the Heading field.

3. Click the browse button for the Formula field, to open the Formula Editor window.

4. In the Formula field of the Formula Editor window, paste the formula you used to create the Vacation column, and change ‘Vacation’ to ‘Holiday’.

This formula will result in the column displaying only hours that have an Activity of Holiday.

Page 35: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a payroll service input worksheet

Inquiry Formulas 35

5. Click OK in the Formula Editor window and the General tab to view the new Holiday column in the inquiry and scroll through the data.

Verifying the formula columns and changing the inquiry 1. In the inquiry, compare the Hours Type and Activity columns with what

appears in the Regular, Overtime, Vacation, Sick, and Holiday columns and notice that their formulas are correct.

2. Remove the following columns by right-clicking the column heading and clicking Remove column for each column:

Transaction Type

Activity

Hours Type

Page 36: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Producing a payroll service input worksheet

36 Inquiry Formulas

3. Right-click the Date column and click Properties.

4. On the General tab:

Change the Width to 1.50 inches.

Click OK.

5. Right-click the Employee column and click Group collapsed.

6. The inquiry now reports hours for each payroll category for any range of dates, which you can select in the Inquiry Properties window.

Page 37: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Appendix A

Inquiry Formulas 37

Appendix A: Advanced custom formulas If you are an advanced user and have experience with SQL, you may be interested in advanced custom formulas.

When you create a formula, you can use other existing formulas in the inquiry. These appear in the Available Columns area of the Formula Editor. The Available Columns area also contains the Current User Key, which allows you to display inquiry data pertaining only to the user.

Warning! When you create advanced custom formulas, be aware that when Ajera’s database structure or logic changes, advanced custom formulas may cease to work correctly. These formulas may produce an error or, worse, return incorrect results without alerting you of any problems.

For example, if you create an advanced custom formula that calculates an activity type total using the current activity types, and then a future version of Ajera’s database includes new activity types, that formula then produces an inaccurate amount because it is calculated without the new activity types.

Also, multiple custom formulas on one inquiry may cause performance issues.

Use for static information You may choose to write an advanced custom formula when you need to create an entirely new column that is not based on a relationship between existing columns.

To write this kind of formulas, you must know the structure of the Ajera database. To determine the database structure, you can export your data into SQL Server Management Studio Tool.

Because Axium does not notify you when it changes Ajera’s database structure or logic, it is best to use advanced custom formulas to retrieve static information from different inquiries, or tables, within the database, rather than dynamic information.

Sample formulas

Following are two sample formulas that retrieve static information from different database tables:

You want a column for the project manager’s phone number on the Project inquiry. To do this, you must create a custom formula on the Project inquiry referencing the phone number field from the Employee database table:

SELECT vecPhone1 FROM AxVec WHERE vecKey = [Project Manager Key]

You want to apply a date range to an advanced custom formula. To do this, the formula must use the SQL Min/Max function, and the function must contain these dates: 01-01-1900 and 12-31-2078. For example:

SELECT (hours) = sum(tunits) FROM axtransaction WHERE ttype in (0,2) and tiscurrent = 1 AND tdate BETWEEN '01-01-1900' and '12-31-2078'

You must close the Properties window and reopen it for the Date Range field to appear.

Page 38: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Appendix A

38 Inquiry Formulas

Common SQL statements and clauses The most common operation in SQL is the query. Queries retrieve data from one or more database tables or expressions based on specific criteria.

The following SQL statements and clauses are often used in queries.

SELECT

Use the SELECT statement to specify the columns from which you want to retrieve data. Standard SELECT statements do not affect the database.

The SELECT statement is complex, and you can use it with a variety of functions and clauses, such as FROM, WHERE, and GROUP BY.

Syntax

SELECT statement ::=

[WITH <common_table_expression> [,...n]]

<query_expression>

[ ORDER BY { order_by_expression | column_position [ ASC | DESC ] }

[ ,...n ] ]

[ COMPUTE

{ { AVG | COUNT | MAX | MIN | SUM } ( expression ) } [ ,...n ]

[ BY expression [ ,...n ] ]

]

[ <FOR Clause>]

[ OPTION ( <query_hint> [ ,...n ] ) ]

<query_expression> ::=

{ <query_specification> | ( <query_expression> ) }

[ { UNION [ ALL ] | EXCEPT | INTERSECT }

<query_specification> | ( <query_expression> ) [...n ] ]

<query_specification> ::=

SELECT [ ALL | DISTINCT ]

[TOP expression [PERCENT] [ WITH TIES ] ]

< select_list >

[ INTO new_table ]

[ FROM { <table_source> } [ ,...n ] ]

[ WHERE <search_condition> ]

[ GROUP BY [ ALL ] group_by_expression [ ,...n ]

[ WITH { CUBE | ROLLUP } ]

]

[ HAVING < search_condition > ]

Page 39: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Appendix A

Inquiry Formulas 39

FROM

Use the FROM clause in a SELECT statement to specify the table or view from which you want to retrieve data.

Syntax

[ FROM { <table_source> } [ ,...n ] ] <table_source> ::= { table_or_view_name [ [ AS ] table_alias ] [ <tablesample_clause> ] [ WITH ( < table_hint > [ [ , ]...n ] ) ] | rowset_function [ [ AS ] table_alias ] [ ( bulk_column_alias [ ,...n ] ) ] | user_defined_function [ [ AS ] table_alias ] [ (column_alias [ ,...n ] ) ] | OPENXML <openxml_clause> | derived_table [ AS ] table_alias [ ( column_alias [ ,...n ] ) ] | <joined_table> | <pivoted_table> | <unpivoted_table> | @variable [ [ AS ] table_alias ] | @variable.function_call ( expression [ ,...n ] ) [ [ AS ] table_alias ] [ (column_alias [ ,...n ] ) ]}<tablesample_clause> ::= TABLESAMPLE [SYSTEM] ( sample_number [ PERCENT | ROWS ] ) [ REPEATABLE ( repeat_seed ) ] <joined_table> ::= { <table_source> <join_type> <table_source> ON <search_condition> | <table_source> CROSS JOIN <table_source> | left_table_source { CROSS | OUTER } APPLY right_table_source | [ ( ] <joined_table> [ ) ] } <join_type> ::= [ { INNER | { { LEFT | RIGHT | FULL } [ OUTER ] } } [ <join_hint> ] ] JOIN <pivoted_table> ::= table_source PIVOT <pivot_clause> table_alias <pivot_clause> ::= ( aggregate_function ( value_column ) FOR pivot_column IN ( <column_list> ) ) <unpivoted_table> ::= table_source UNPIVOT <unpivot_clause> table_alias

Page 40: Inquiry Formulas - Deltek | Axium... a string function. You will also learn how to use ... to” or access information between database ... You can write many different inquiry formulas

Appendix A

40 Inquiry Formulas

<unpivot_clause> ::= ( value_column FOR pivot_column IN ( <column_list> ) ) <column_list> ::= column_name [ ,...n ]

WHERE

Use the WHERE clause in a SELECT statement to create a search condition that limits the rows displayed by a query.

Syntax

WHERE <search_condition>

GROUP BY

Use the GROUP BY clause in a SELECT statement to specify how the output rows are organized in the query.

Syntax

[ GROUP BY [ ALL ] group_by_expression [ ,...n ] [ WITH { CUBE | ROLLUP } ] ]