Bewerken

Share via


attribute element

Specifies a column from an entity or link-entity to return with a query.

Learn how to select columns using FetchXml.

Example

<fetch>
  <entity name='account'>
    <attribute name='name' />
    <link-entity name='contact'
      from='contactid'
      to='primarycontactid'
      link-type='inner'
      alias='contact'>
      <attribute name='fullname' />
    </link-entity>
  </entity>
</fetch>

Attributes

Name Required? Description
aggregate No The aggregate function to apply. Learn how to aggregate data with FetchXml
alias No The name of the column to return. Each column must have a unique name. You'll use aliases when you retrieve aggregate values. Learn more about column aliases.
dategrouping No When you group data by a datetime value, this attribute specifies the date part to use. See Date grouping options
distinct No When you use the aggregate countcolumn function, this attribute specifies that only unique values for the column are returned. Learn more about distinct column values.
groupby No When you aggregate data, this attribute specifies the column to use to group the data. Learn more about grouping.
name Yes The logical name of the column.
rowaggregate No When this value is set to CountChildren a value that includes the total number of child records for the record is included in the results. Learn how to use this attribute.
usertimezone No Used by aggregate queries that group by datetime columns. Depending on the time zone, the same datetime value can fall in different days. Learn about grouping by parts of a date

Use this attribute with a false value to force the grouping to use UTC value. When you don't set this attribute, the default value is true, and the user's time zone is used.

Note: With QueryExpression, the grouping always uses UTC. When using the SDK FetchXmlToQueryExpressionRequest class, this setting is lost. There's no way to set this using QueryExpression.

Parent elements

Name Description
entity Specifies the child element for a fetch element, the 'parent entity' for the query. Only one entity is allowed.
link-entity Joins a table related to the entity or link-entity to return additional columns with the result. Also used with filter elements to apply conditions on column values in related tables.

Aggregate functions

Use these aggregate functions. Learn how to aggregate data with FetchXml

Function Return value
avg The average value of the column values with data.
count The number of rows.
countcolumn The number of rows with data in that column.
max The maximum value of the rows in that column.
min The minimum value of the rows in that column.
sum The total value of the column values with data.

Date grouping options

Learn more about grouping by parts of a date

Value Description
day Group by day of the month
week Group by week of the year
month Group by month of the year
quarter Group by quarter of the fiscal year
year Group by the year
fiscal-period Group by period of the fiscal year
fiscal-year Group by the fiscal year

Learn more about fiscal year settings