TRVCrossTabLevel.DataQuery

<< Click to display table of contents >>

TRVCrossTabLevel.DataQuery

A data query for cross-tab columns generation.

property DataQuery: TRVUnicodeString;

This property is used only if TRVReportTableItemInfo.CrossTabulation.ColumnGenerationType = rvcgtDataQuerySeparate or rvcgtDataQueryCascade.

If there is only one cross-tab level (i.e. TRVReportTableItemInfo.CrossTabulation.Levels.Count = 1), these generation types are identical. The difference exists only if there are two or more cross-tab levels.

ColumnGenerationType

Comments

rvcgtDataQuerySeparate

All Table.CrossTabulation.Levels[].DataQuery are independent from each other.

Each such a data query is executed only once.

If each level of cross-tab repeats the same group of data, use this generation type, because it is more efficient.

rvcgtDataQueryCascade

Table.CrossTabulation.Levels[].DataQuery may refer to data queries of higher levels.

I.e. the N-th data query may use the results of 0..N-1 data queries.

Values for cross-tab columns generation are taken from DataQueryFieldName field of the result of application of DataQuery. If DataQueryFieldName is empty, FieldName field is used.

This field must be of one of the following types:

rvrftText,

rvrftInteger,

rvrftFloat,

rvrftBoolean,

rvrftDateTime, rvrftDate, rvrftTime

The values used for column generation are ordered as they appear in records returned by an application of DataQuery. Only unique values are used, without repetitions. When comparing text values (to remove duplicates), CaseSensitive property is taken into account.

Example:

Let we have the following tables:

'QuestionsTable' containing identifiers and text of poll questions.

'QuestionOptionsTable' containing identifiers and text of possible answers to questions.

Table.CrossTabulation.ColumnGenerationType := rvcgtDataQueryCascade;

Table.CrossTabulation.Column := 1;
Table.CrossTabulation.FirstRow := 0;
with Table.CrossTabulation.Levels.Add do
begin
  DataQuery := 'SELECT QuestionText, QuestionId FROM QuestionsTable';
  FieldName := 'QuestionId';

  CaptionFieldName := 'QuestionText';
end;

with Table.CrossTabulation.Levels.Add do
begin
  DataQuery := 'SELECT OptionText, OptionId FROM QuestionsOptionsTable WHERE QuestionId={#QuestionId}';
  FieldName := 'QuestionId';

  CaptionFieldName := 'QuestionText';
end;

The report template table may look like:

Age

{#QuestionText}

{#OptionText}

{Age}

{Percent}%

The resulting table may look like:

Age

Do you ... ?

Are you ... ?

yes

no

yes,
completely

yes,
partially

no

15 and under

10%

90%

25%

50%

25%

16-25

21%

79%

50%

25%

25%

26-40

1%

99%

15%

60%

25%

over 40

90%

10%

0%

100%

0%

Default value:

'' (empty string)

See also

Definitions of Report Workshop terms

Information about data queries

TRVReportDocObject.DataQuery

TRVRowGenerationRule.DataQuery

TRVReportTableCellData.DataQuery