Data Composition System Expression Language (1Cv8). Useful examples of drawing up a data layout diagram CDS calculated function fields

Login to the site as a student

Log in as a student to access school materials

Data composition system 1C 8.3 for beginners: counting the results (resources)

The purpose of this lesson will be:

  • Write a report that displays a list of products (Food directory), their calorie content and taste.
  • Group products by color.
  • Learn about summarizing (resources) and calculated fields.

Create a new report

As in previous lessons, we open the database " Deli"in the configurator and create a new report through the menu" File"->"New...":

Document type - external report:

In the report setup form, write the name " Lesson3" and press the button " Open data composition diagram":

Leave the default schema name and click the " Ready":

Adding a request through the constructor

On the tab " Data set" click green plus sign and select " Add Dataset - Query":

Instead of writing the request text manually, we run it again query constructor:

On the "tab" Tables"drag the table" Food" from the first column to the second:

Select from the table " Food"fields that we will request. To do this, drag and drop the fields" Name", "Taste", "Color" And " Calorie content" from the second column to the third:

It turned out like this:

Press the button " OK" - the request text was generated automatically:

Creating report presentation settings

Go to the tab " Settings" and click on magic wand, to call settings designer:

Select the report type " List..." and press the button " Further":

Drag from the left column to the right the fields that will be displayed in the list and click " Further":

Drag from the left column to the right field " Color" - it will happen grouping lines in the report. Click " OK":

And here is the result of the designer’s work. Hierarchy of our report:

  • the report as a whole
  • grouping "Color"
  • detailed entries - lines with food names

Save the report (button diskette) And without closing We will immediately open the configurator in user mode. It turned out like this:

Changing the order of columns

But let's let's change the order columns (up and down arrows) so that it looks like the figure below:

Let's save the report and open it again in user mode:

Great, that's much better.

Let's sum up the calorie content

It would be nice to summarize the calorie content of foods by group. To see the sum of the calorie content of all products, say, white or yellow. Or find out the total calorie content of all products in the database.

For this purpose, there is a mechanism for calculating resources.

Go to the tab " Resources"and drag the field" Calorie content"(we are going to summarize it) from the left column to the right.

In this case, in the field, select the expression from the drop-down list " Amount(Calorie)", since the total will be the sum of all elements included in the total:

We save and generate a report:

We now have results for each of the groups and for the report as a whole.

Let's sum it up (average) in terms of calories

Now let's make it appear in another column average calorie content of products by groups and in the report as a whole.

You cannot touch the existing “Calorie” column - the total is already displayed in it, so let's create another field, which will be an exact copy of the "Calorie" field.

To create such a “virtual” field, we will use the mechanism calculated fields.

Go to the tab " Calculated fields" and press green plus sign:

In a collumn " Data path"we write the name of the new field ( seamlessly, without spaces). Let it be called " Average Calorie Content", and in the column " Expression"we write the name of an existing field on the basis of which the new field will be calculated. We write there " Calorie content". Column " Heading" will be filled in automatically.

We have added a new field (" Average Calorie Content"), but it will not appear in the report by itself - you need to either call again settings designer("magic wand") or add this field manually.

Let's do it second way. To do this, go to the tab " Settings", select " Report"(after all, we want to add the field as a whole to the report), select the tab at the bottom" Selected fields"and drag the field" Average Calorie Content"from the left column to the right:

It turned out like this:

We save and generate a report:

The field has appeared and we see that its values ​​are the values ​​of the "Calorie" field. Great!

To do this, we will again use the mechanism already familiar to us resources(summarizing). Go to the tab " Resources"and drag the field" Average Calorie Content"from the left column to the right:

Moreover, in the column " Expression"choose" Average(AverageCalorie)":

We save and generate a report:

We see that for the groups, that is, for each color, and for the report as a whole, the average value was calculated absolutely correctly. But they are present extra entries for individual products (not groups) that I would like to remove from the report.

Do you know why they appeared (values ​​not by group)? Because when we added the field " Average Calorie Content"in the report settings, in the second step we selected the entire report and this new field ended up in the element " Detailed records".

Let's fix the error. To do this, go back to the tab " Settings", select " Detailed entries" first from above (step 2) and then " Detailed entries"from below (step 3), go to the bookmark" Selected fields" and we will see in its right column the element " Auto".

Element " Auto" - this is not one field. These are several fields that fall here automatically based on higher-level settings.

To see what these fields are, click on the element " Auto" right button and select " Expand":

Element " Auto" expanded into the following fields:

And here is our field" Average Calorie Content"which came here from the point " Report" when we dragged him there. Just let's remove check the box next to this field to remove its output.

In light of the upcoming release of 8.2.14, I will try to describe some new functions of the data composition system.

Open the data layout diagram, preferably in an external report, to make editing easier.

We add a dataset of the query type and write, either manually or using the query designer, a simple query:

1. Set up a request in the access control system.

2. Set up calculated fields in the access control system

3. Configure the data layout on the settings tab

4. Launch 1C Enterprise 8.2.14. Open the report. We form, we receive.

Description of the new functions themselves:

1. The current date()

Returns the system date. When composing a layout layout, in all expressions that are present in the layout, the CurrentDate() function is replaced with the value of the current date.

2. COMPUTEEXPRESSION()

Syntax:

CalculateExpression(,)

Description:

The function is designed to evaluate an expression in the context of some grouping.

The function takes into account the selection of groupings, but does not take into account hierarchical selections.

The function cannot be applied to a grouping in the group selection of that grouping. For example, in selecting the Nomenclature grouping, you cannot use the expression CalculateExpression("Sum(SumTurnover)", "TotalTotal") > 1000. But such an expression can be used in hierarchical selection.

If the end record precedes the start record, then it is considered that there are no records for calculating detailed data and calculating aggregate functions.

When calculating interval expressions for a grand total (the Grouping parameter is set to GrandTotal), it is assumed that there are no records for calculating detailed data and calculating aggregate functions.

Layout linker when generating a function expression CalculateExpression, if the ordering expression contains fields that cannot be used in grouping, replaces the function CalculateExpression on NULL.

Options

Type: Line. The expression to be evaluated.

Type: Line. Contains the name of the grouping in the context of which the expression is to be evaluated. If an empty string is used as the grouping name, the calculation will be performed in the context of the current grouping. If the GeneralTotal string is used as the group name, the calculation will be performed in the context of the grand total. Otherwise, the calculation will be performed in the context of the parent grouping with the same name.

For example:

Sum(Sales.SumTurnover)/Calculate("Sum(Sales.SumTurnover)", "Total")

In this example, the result will be the ratio of the sum by field Sales.AmountTurnover grouping records to the sum of the same field in the entire layout;

Type: Line. The parameter can take the following values:

· Grand total— the expression will be calculated for all grouping records.

· Hierarchy— the expression will be evaluated for the parent hierarchical record, if there is one, and for the entire grouping, if there is no parent hierarchical record.

· Grouping— the expression will be evaluated for the current group grouping record.

· GroupingNonResource— when calculating a function for a group record by resources, the expression will be calculated for the first group record of the original grouping.

When calculating a function CalculateExpression() with meaning GroupingNonResource for group records that are not grouped by resources, the function is calculated in the same way as it would be calculated if the parameter value was equal to the value Grouping.

The data composition layout builder, when generating a data composition layout when outputting the resource field by which grouping is performed to the layout, places an expression in the layout that is calculated using the function CalculateExpression() , indicating the parameter GroupingNonResource. For other resources, the usual resource expressions are placed in the resource grouping.

Type: Line. Indicates from which record the fragment should begin, in which aggregate expression functions should be calculated, and from which record to obtain field values ​​outside of aggregate functions. The value can be one of the following:

· First

· Last (Last)

· Previous

· Next (Next)

· Current

· LimitingValue(BoundaryValue) LimitingValue

Type: Line. Indicates to which record the fragment should be continued, in which the aggregate functions of the expression should be calculated. The value can be one of the following:

· First. It is necessary to obtain the first grouping record. After the word in brackets, you can specify an expression, the result of which will be used as an offset from the beginning of the grouping. The resulting value must be an integer greater than zero. For example, First(3) - receiving the third record from the beginning of the grouping.

If the first record is outside the grouping, then it is considered that there are no records. For example, if there are 3 records, and you want to get First(4), then it is considered that there are no records.

· Last (Last). You need to get the last grouping record. After the word in brackets, you can specify an expression, the result of which will be used as an offset from the end of the grouping. The resulting value must be an integer greater than zero. For example, Last(3) - receiving the third record from the end of the group.

If the last record is outside the grouping, then it is considered that there are no records. For example, if there are 3 records, and you want to get Last(4), then it is considered that there are no records.

· Previous. You need to get the previous grouping record. After the word in brackets, you can specify an expression, the result of which will be used as an offset back from the current grouping record. For example, Previous(2) - getting the previous from the previous record.

If the previous record goes beyond the grouping (for example, for the second grouping record you need to get Previous(3)), then the first grouping record is obtained.

When retrieving the previous record for a grouping total, it is considered that the first record is obtained.

· Next (Next). You need to get the next grouping record. After the word in brackets, you can specify an expression, the result of which will be used as an offset forward from the current grouping entry. For example, Next(2) - getting next from the next record.

If the next record goes beyond the grouping, then it is considered that there are no records. For example, if there are 3 entries and the third entry receives Next() , then it is considered that there are no entries.

When the next record is received for the grouping total, it is considered that there is no record.

· Current. You need to get the current record.

When retrieving for a grouping total, the first record is obtained.

· LimitingValue(BoundaryValue). The need to obtain a record by the specified value. After the word LimitingValue in brackets you need to indicate the expression with the value of which you want to start the fragment, the first ordering field.

The first record whose ordering field value is greater than or equal to the specified value will be returned as the record. For example, if the Period field is used as the ordering field, and it has the values ​​01/01/2010, 02/01/2010, 03/01/2010, and you want to get LimitingValue(DateTime(2010, 1, 15)), then a record with the date 02/01/2010 will be received.

Type: Line. Lists expressions, separated by commas, that describe the ordering rules. If not specified, then the ordering is performed in the same way as for the grouping for which the expression is evaluated. After each expression you can specify a keyword Age(for ordering in ascending order), Descending(for ordering in descending order) and Auto-order(to order reference fields by the fields by which you want to order the referenced object). Word Auto-order can be used as with the word Age, so with the word Descending.

Type: Line. Same as parameter Sorting. Used to organize hierarchical records. If not specified, the layout builder generates the ordering according to the ordering specified in the parameter Sorting.

Type: Line. Specifies the rule for determining the previous or next record in case there are several records with the same ordering value:

· Separately indicates that a sequence of ordered records is used to determine the previous and next records. Default value.

· Together indicates that the previous and next records are determined based on the values ​​of the ordering expressions.

For example, if the resulting sequence is ordered by date:

date Full name Meaning
1 January 01, 2001

Ivanov M.

10
2 02 January 2001 Petrov S. 20
3 January 03, 2001 Sidorov R. 30
4 04 January 2001 Petrov S. 40

Separately, That:

§ the previous entry to entry 3 will be entry 2.

Current, Current(accordingly, parameters Start And End), then for record 2 this fragment will consist of one record 2. The expression will be equal to 20.

If the parameter value is Together, That:

§ the previous entry to entry 3 will be entry 1.

§ if the calculation fragment is defined as Current, Current(accordingly, parameters Start And End), then for record 2 this fragment will consist of records 2 and 3. Expression CalculateExpression("Sum(Value)", Current, Current) will be equal to 50.

When specifying a parameter value equal to Together, in parameters Start And End you cannot specify an offset for positions First, Last, Previous, Next.

CalculateExpression("Sum(SumTurnover)", "First", "Current")

If you want to get the grouping value in the previous line, you can use the following expression:

CalculateExpression("Rate", "Previous")

List new functions:

CalculateExpressionWithGroupArray(,) -

The function returns an array, each element of which contains the result of evaluating an expression for grouping by the specified field.

CalculateExpressionWithGroupValueTable(,) -

The function returns a table of values, each row of which contains the result of evaluating expressions for grouping by the specified field

ValueFilled() - Returns True if the value is other than the default value of this type, other than NULL, other than an empty reference, other than Undefined. Boolean values ​​are checked for NULL values. Strings are checked for the absence of non-whitespace characters

Format(, ) - Receive a formatted string of the passed value. The format string is set in accordance with the format string of the 1C:Enterprise system.

Substring(, , ) - This function is designed to extract a substring from a string.

Line Length() - The function is designed to determine the length of a string. Parameter is a string expression

Line() - If an array is passed as a parameter, the function returns a string containing string representations of all array elements, separated by "; " characters. If a table of values ​​is passed as a parameter, the function returns a string containing string representations of all rows of the table of values, with the cell representations of each row separated by ";" characters, and the rows by a newline character. If an element's string representation is empty, then a string is displayed instead of its representation.

CalculateExpression is a rather difficult ACS function to understand, and examples of application in the reference information are quite scarce. This article discusses examples that are sure to be useful to every developer:

  1. cumulative total in grouping;
  2. cumulative total in a cross-tab;
  3. getting the previous value;
  4. PM output in one line.

1. Obtaining an indicator on an accrual basis

Let's get the quantity of goods as a cumulative total at the grouping level. To do this, create a calculated field (see Figure 1).
On the "Resources" tab, set the function for the calculated field:
CalculateExpression("Sum(QuantityTurnover)", "First", "Current")
which will sum the number of products from the first record to the current one (see Figure 2).

If the cumulative total quantity of an item needs to be obtained at the level of detailed records, then we set the CalculateExpression function for the calculated field on the “Calculated fields” tab (see Figure 3).
Depending on the level of obtaining the cumulative total, we create a grouping (see Figure 4): at the resource level - grouping by goods, at the remote control level - grouping of detailed records.
Figure 4. Report groupings with cumulative totals

2. Getting the indicator value from the previous row

Let's get the exchange rate for the date and the previous date. To do this, create a calculated field and write the following expression in the expression field (see Figure 5):
CalculateExpression("Rate", "Previous", "Previous")
which will take the previous value of the exchange rate for the current row, the last parameter of the function limits the receipt of data.
Since we are working at the level of detailed records, we immediately go to the “Settings” tab and create a grouping - detailed records.

3. Obtaining an indicator as a cumulative total in a cross-tab

Let's get the quantity of goods on an accrual basis by period. To do this, create a calculated field (see Figure 1). On the "Resources" tab, we specify the following expression for the calculated field (see Figure 6):
CalculateExpression("Sum(QuantityTurnover)", "Period", "First", "Current")
which at the grouping level will calculate the quantity of goods in the interval from the first line to the current one in the context of the period for each item.
On the “Settings” tab, create a table with grouping by item in a row and grouping by period in a column (see Figure 7).

4. Outputting tabular data in one line

Methods for displaying tabular data in one line, including the method using the CalculateExpression function, are discussed in the article

Data Composition System Expression Language

The data composition system expression language is designed to write expressions used in various parts of the system.

Expressions are used in the following subsystems:

  • data layout diagram - to describe calculated fields, total fields, connection expressions, etc.;
  • data layout settings - to describe custom field expressions;
  • data layout layout - for describing expressions for connecting data sets, describing layout parameters, etc.

Literals

The expression may contain literals. The following types of literals are possible:

  • Line;
  • Number;
  • Date of;
  • Boolean.

Line

A string literal is written in “” characters, for example:

“String literal”

If you need to use the “” character inside a string literal, you should use two such characters.

For example:

“Literal ““in quotes”““

Number

The number is written without spaces, in decimal format. The fractional part is separated using the "." symbol. For example:

10.5 200

date

A date literal is written using the key literal DATETIME. After this keyword, the year, month, day, hours, minutes, seconds are listed in parentheses, separated by commas. Time specification is not required.

For example:

DATETIME(1975, 1, 06) – January 6th, 1975 DATETIME(2006, 12, 2, 23, 56, 57) – December 2nd, 2006, 23 hours 56 minutes 57 seconds, 23 hours 56 minutes 57 seconds

Boolean

Boolean values ​​can be written using the literals True (True), False (False).

Meaning

To specify literals of other types (system enumerations, predefined data), the keyword Value is used, followed by the name of the literal in parentheses.

Value(AccountType. Active)

Operations on numbers

Unary –

This operation is intended to change the sign of a number to the opposite sign. For example:

Sales.Quantity

Unary +

This operation does not perform any actions on the number. For example:

Sales.Quantity

Binary -

This operation is intended to calculate the difference of two numbers. For example:

ResidualsAndTurnovers.InitialRemaining – RemainingsAndTurnovers.FinalResidualsRemainingsAndTurnovers.InitialRemaining - 100 400 – 357

Binary +

This operation is designed to calculate the sum of two numbers. For example:

RemainingsAndTurnover.InitialRemaining + RemainingAndTurnover.Turnover ResiduesAndTurnover.InitialRemaining + 100 400 + 357

Work

This operation is designed to calculate the product of two numbers. For example:

Nomenclature.Price * 1.2 2 * 3.14

Division

This operation is designed to obtain the result of dividing one operand by another. For example:

Nomenclature.Price / 1.2 2 / 3.14

Remainder of the division

This operation is designed to obtain the remainder when one operand is divided by another. For example:

Nomenclature. Price % 1.2 2 % 3.14

String Operations

Concatenation (Binary +)

This operation is designed to concatenate two strings. For example:

Nomenclature.Article + “: ”+ Nomenclature.Name

Like

This operation checks whether the string matches the passed pattern.

The value of the LIKE operator is TRUE if the value<Выражения>satisfies the pattern, and FALSE otherwise.

The following characters in<Строке_шаблона>have a meaning different from just another character in the line:

  • % - percentage: a sequence containing zero or more arbitrary characters;
  • _ - underscore: one arbitrary character;
  • […] - one or more characters in square brackets: one character, any of those listed inside the square brackets. The enumeration may contain ranges, for example a-z, meaning an arbitrary character included in the range, including the ends of the range;
  • [^...] - in square brackets a negation icon followed by one or more characters: any character except those listed after the negation icon;

Any other symbol means itself and does not carry any additional load. If one of the listed characters needs to be written as itself, then it must be preceded by<Спецсимвол>, specified after the SPECIAL CHARACTER keyword (ESCAPE).

For example, template

“%ABV[abvg]\_abv%” SPECIAL CHARACTER “\”

means a substring consisting of a sequence of characters: the letter A; letters B; letters B; one digit; one of the letters a, b, c or d; underscore; letters a; letters b; letters v. Moreover, this sequence can be located starting from an arbitrary position in the line.

Comparison Operations

Equals

This operation is intended to compare two operands for equality. For example:

Sales.Counterparty = Sales.NomenclatureMainSupplier

Not equal

This operation is intended to compare two operands for inequality. For example:

Sales.Counterparty<>Sales.NomenclatureMainSupplier

Less

This operation is designed to check that the first operand is less than the second. For example:

SalesCurrent.Amount< ПродажиПрошлые.Сумма

More

This operation is designed to check that the first operand is greater than the second. For example:

SalesCurrent.Sum > SalesPast.Sum

Less or equal

This operation is designed to check that the first operand is less than or equal to the second. For example:

SalesCurrent.Amount<= ПродажиПрошлые.Сумма

More or equal

This operation is designed to check that the first operand is greater than or equal to the second. For example:

SalesCurrent.Amount >= SalesPast.Amount

Operation B

This operation checks for the presence of a value in the passed list of values. The result of the operation will be True if the value is found, or False otherwise. For example:

Item B (&Product1, &Product2)

Operation of checking the presence of a value in a data set

The operation checks for the presence of a value in the specified data set. The validation dataset must contain one field. For example:

Sales. Counterparty To Counterparties

Operation of checking a value for NULL

This operation returns True if the value is NULL. For example:

Sales.Counterparty IS NULL

Operation of checking a value for NULL inequality

This operation returns True if the value is not NULL. For example:

Sales. Counterparty IS NOT NULL

Logical operations

Logical operations accept expressions of type Boolean as operands.

Operation NOT

The NOT operation returns True if its operand is False and False if its operand is True. For example:

NOT Document.Consignee = Document.Consignor

Operation I

The AND operation returns True if both operands are True, and False if one of the operands is False. For example:

Document.Consignee = Document.Consignor AND Document.Consignee = &Counterparty

OR operation

The OR operation returns True if one of its operands is True, and False if both operands are False. For example:

Document.Consignee = Document.Consignor OR Document.Consignee = &Counterparty

Aggregate functions

Aggregate functions perform some action on a set of data.

Sum

The aggregate function Sum calculates the sum of the values ​​of the expressions passed to it as an argument for all detail records. For example:

Amount(Sales.AmountTurnover)

Quantity

The Count function calculates the number of values ​​other than NULL. For example:

Quantity(Sales.Counterparty)

Number of different

This function calculates the number of distinct values. For example:

Quantity(Various Sales.Counterparty)

Maximum

The function gets the maximum value. For example:

Maximum(Remaining.Quantity)

Minimum

The function gets the minimum value. For example:

Minimum(Remaining.Quantity)

Average

The function gets the average of non-NULL values. For example:

Average(Remaining.Quantity)

Other operations

Operation SELECT

The Select operation is intended to select one of several values ​​when certain conditions are met. For example:

Select When Amount > 1000 Then Amount Otherwise 0 End

Rules for comparing two values

If the types of the values ​​being compared are different from each other, then the relationships between the values ​​are determined based on the precedence of the types:

  • NULL (lowest);
  • Boolean;
  • Number;
  • Date of;
  • Line;
  • Reference types

The relationships between different reference types are determined based on the reference numbers of the tables corresponding to a particular type.

If the data types are the same, then the values ​​are compared according to the following rules:

  • for the Boolean type the value TRUE is greater than the value FALSE;
  • the Number type has the usual comparison rules for numbers;
  • for the Date type, earlier dates are smaller than later ones;
  • for the String type - comparison of strings in accordance with the established national characteristics of the database;
  • reference types are compared based on their values ​​(record number, etc.).

Working with NULL Value

Any operation in which one of the operands is NULL will produce a NULL result.

There are exceptions:

  • The AND operation will return NULL only if none of the operands is False;
  • The OR operation will only return NULL if none of its operands are True.

Operation priorities

The operations have the following priorities (the first line has the lowest priority):

  • B, IS NULL, IS NOT NULL;
  • =, <>, <=, <, >=, >;
  • Binary +, Binary – ;
  • *, /, %;
  • Unary +, Unary -.

Data Composition System Expression Language Functions

Calculate

The Calculate function is designed to calculate an expression in the context of a certain grouping. The function has the following parameters:

  • Expression. Type String. Contains a calculated expression;
  • Grouping. Type String. Contains the name of the grouping in the context of which the expression is to be evaluated. If an empty string is used as the grouping name, the calculation will be performed in the context of the current grouping. If the GrandTotal string is used as the group name, the calculation will be performed in the context of the grand total. Otherwise, the calculation will be performed in the context of the parent grouping with the same name. For example:
Sum(Sales.SumTurnover) / Calculate("Sum(Sales.SumTurnover)", "Total")

In this example, the result will be the ratio of the amount for the "Sales.AmountTurnover" field of the grouping record to the amount of the same field in the entire layout.

Level

The function is designed to obtain the current recording level.

Level()

NumberInOrder

Get the next sequence number.

NumberByOrder()

NumberInOrderInGrouping

Returns the next ordinal number in the current grouping.

NumberByOrderInGroup()

Format

Get a formatted string of the passed value.

The format string is set in accordance with the 1C:Enterprise format string.

Options:

  • Meaning;
  • Format string.

Format(Consumable Invoices.Doc Amount, "NPV=2")

Beginning of period

Options:

    • Minute;
    • Day;
    • A week;
    • Month;
    • Quarter;
    • Decade;
    • Half year.

StartPeriod(DateTime(2002, 10, 12, 10, 15, 34), "Month")

Result:

01.10.2002 0:00:00

End of Period

The function is designed to extract a specific date from a given date.

Options:

  • Date of. Type Date. Specified date;
  • Period type. Type String. Contains one of the following values:
    • Minute;
    • Day;
    • A week;
    • Month;
    • Quarter;
    • Decade;
    • Half year.

EndPeriod(DateTime(2002, 10, 12, 10, 15, 34), "Week")

Result:

13.10.2002 23:59:59

AddToDate

The function is designed to add a certain value to a date.

Options:

  • Magnification type. Type String. Contains one of the following values:
    • Minute;
    • Day;
    • A week;
    • Month;
    • Quarter;
    • Decade;
    • Half year.
  • Amount – by how much you need to increase the date. Type Number. The fractional part is ignored.

AddToDate(DateTime(2002, 10, 12, 10, 15, 34), "Month", 1)

Result:

12.11.2002 10:15:34

Date Difference

The function is designed to get the difference between two dates.

Options:

  • Expression. Type Date. Original date;
  • Expression. Type Date. Subtracted date;
  • Difference type. Type String. Contains one of the following values:
    • Second;
    • Minute;
    • Day;
    • Month;
    • Quarter;

DATEDIFFERENCE(DATETIME(2002, 10, 12, 10, 15, 34), DATETIME(2002, 10, 14, 9, 18, 06), "DAY")

Result:

Substring

This function is designed to extract a substring from a string.

Options:

  • Line. Type String. The string from which the substring is extracted;
  • Position. Type Number. The position of the character from which the substring to be extracted from the string begins;
  • Length. Type Number. Length of the allocated substring.

SUBSTRING(Accounts.Address, 1, 4)

Line Length

The function is designed to determine the length of a string.

Parameter:

  • Line. Type String. A string whose length is specified.

Line(Counterparties.Address)

Year

This function is designed to extract the year from a Date type value.

Parameter:

  • Date of. Type Date. The date by which the year is determined.

YEAR(Expense.Date)

Quarter

This function is designed to extract the quarter number from a Date type value. The quarter number normally ranges from 1 to 4.

Parameter

  • Date of. Type Date. The date by which the quarter is determined
QUARTER(Expense.Date)

Month

This function is designed to extract the month number from a Date type value. The month number normally ranges from 1 to 12.

  • Date of. Type Date. The date by which the month is determined.
MONTH(Expense.Date)

Day of the Year

This function is designed to obtain the day of the year from a Date type value. The day of the year normally ranges from 1 to 365 (366).

  • Date of. Type Date. The date by which the day of the year is determined.
DAYYEAR(ExpenseAccount.Date)

Day

This function is designed to obtain the day of the month from a Date type value. The day of the month normally ranges from 1 to 31.

  • Date of. Type Date. The date by which the day of the month is determined.
DAY(Expense.Date)

A week

This function is designed to obtain the week number of the year from a Date type value. The weeks of the year are numbered starting from 1.

  • Date of. Type Date. The date by which week numbers are determined.
WEEK(Expense.Date)

Day of the Week

This function is designed to obtain the day of the week from a Date type value. The normal day of the week ranges from 1 (Monday) to 7 (Sunday).

  • Date of. Type Date. The date by which the day of the week is determined.
DAY OF THE WEEK (Expense Invoice Date)

Hour

This function is designed to obtain the hour of day from a Date type value. The hour of the day ranges from 0 to 23.

  • Date of. Type Date. The date by which the hour of the day is determined.
HOUR(Expense.Date)

Minute

This function is designed to obtain the minute of the hour from a Date type value. The minute of the hour ranges from 0 to 59.

  • Date of. Type Date. The date by which the minute of the hour is determined.
MINUTE(Expense.Date)

Second

This function is designed to obtain the second of a minute from a Date type value. The second of a minute ranges from 0 to 59.

  • Date of. Type Date. The date by which the seconds of the minute are determined.
SECOND(Expense.Date)

Express

This function is designed to extract a type from an expression that may contain a compound type. If the expression contains a type other than the required type, NULL will be returned.

Options:

  • Expression to convert;
  • Type indication. Type String. Contains a type string. For example, "Number", "String", etc. In addition to primitive types, this line may contain the name of the table. In this case, an attempt will be made to express a reference to the specified table.

Express(Data.Props1, "Number(10,3)")

IsNull

This function returns the value of the second parameter if the value of the first parameter is NULL.

Otherwise, the value of the first parameter will be returned.

YesNULL(Amount(Sales.AmountTurnover), 0)

Functions of common modules

A data composition engine expression may contain calls to functions of global common configuration modules. No additional syntax is required to call such functions.

In this example, the "AbbreviatedName" function will be called from the general configuration module.

Note that the use of common module functions is only permitted if the appropriate data composition processor parameter is specified.

Additionally, functions of common modules cannot be used in custom field expressions.

Proper use of a data composition scheme (DCS) allows you to:

  • significantly reduce the time required to develop a report;
  • eliminate the need to create a managed form handler;
  • get a beautiful result with the possibility of additional customization by the user.

But not all developers make the most of the scheme’s capabilities, since not all of its settings are obvious and intuitive. In particular, many people know that in 1C SKD there are calculated fields, however, they do not fully understand the scope of their use and methods of working with them.

What is a calculated field

In most cases, the data source in the layout diagram is a query. In principle, within the query itself you can already use various formulas, constructions and expressions. A natural question arises: why do we need duplicate functionality?

The fact is that the access control system is something more than just displaying the result of a query, and this is clearly visible from the diagram creation form (Fig. 1).

Calculated fields allow you to perform certain actions with the generated data set:

  • Output an array of data received by a request into a specific cell, combining several lines into one;
  • Access the export functions of the general module;
  • Execute the various expressions available for the layout language and use the special EvaluateExpression functions.

Let's go through this list.

Array of values ​​in one cell

Let's simulate a situation where it is necessary to receive all receipt document numbers for a counterparty in a separate cell:


Thus, we have created an additional calculation field in our scheme;


As you can see from the example above, there are no difficulties in adding and processing calculated fields. We used two functions: Array() and ConnectRows().

A few words about the latter. In addition to the first parameter indicating the identifier of the array, values ​​or value, two more can be set in it:

  1. Element Separator – indicates which character will separate one array element or one row of a table of values ​​from another (in our case, we omitted this parameter and a line break was assigned by default);
  2. Column Separator – a character used to separate columns of a table of values ​​(semicolon is used by default).

Accessing the export functions of a common module

Functions of a common module can act as a data source for filling a calculated field.

A few important points:

  • The function must be exportable;
  • If a function is located in a common module with the “Global” attribute set, it is called directly by name, otherwise the function must be called according to the “Shared module name” scheme. "Name of the function to be called."

As an example of use, we will take the same request for receipt documents and display it in a separate column. We will not describe the request itself; let’s move directly to the calculated fields:


Thus, we see that almost any data processor can be initialized from the access control system, which significantly expands the possibilities of using the scheme.

Layout language expressions

Quite often in a developer’s work a situation arises when it is necessary to display the result of division in the ACS field:

  1. Calculate the average cost of the item;
  2. All kinds of interest;
  3. Calculations of average earnings, etc.

To avoid problems, in these cases it is advisable to enter a test for division by 0 into the calculated field.

This can be done using the construction “Choice When….Then… Otherwise… End”.

At the end, a few words about the fairly new function CalculateExpression(). With its help, in particular, you can calculate deviations in cost between the current and previous lines, cumulative balance, etc.

Let's say you can get the Document Sum from the previous line of our request by specifying the value Calculate Expression ("Document Sum", "Previous Sum") in the "Expression" field.