{"id":4180,"date":"2021-03-15T19:15:54","date_gmt":"2021-03-15T18:15:54","guid":{"rendered":"https:\/\/help.r2docuo.com\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/"},"modified":"2023-11-21T12:29:09","modified_gmt":"2023-11-21T11:29:09","slug":"detailagg-function-compose-a-field-from-the-data-of-a-detail-tab","status":"publish","type":"ht_kb","link":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/","title":{"rendered":"detailAgg function &#8211; Compose a field from the data of a detail tab"},"content":{"rendered":"<p>This functionality allows you to compose a field using the data from one or more of its child documents in one of its detail tabs.<\/p>\n<p>For example, a document from the <em>Country<\/em> category has several documents from the <em>Province<\/em> category associated with it. And if we want to create a field in <em>Country<\/em> that lists the data of all its <em>Provinces, we<\/em> will use the formula:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\"><tt>Document.detailAgg(List_field, Fields, Separator, Order, [Condici\u00f3n], [Top], [Agrupaci\u00f3n])<br \/>\n<\/tt><\/div>\n<p>Where:<\/p>\n<p><strong>Field_list<\/strong> : is the name of the dropdown list in the child category, where the document of the parent category is selected. Its syntax is that of a tag type:&lt; <strong>@CodeCategory:Group:Field<\/strong>&gt; . For example, in <em>Country<\/em>, we can combine the data of your <em>Provinces<\/em> as follows:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\"><tt>'&lt;@PRV:Data:Country&gt;'<\/tt><\/div>\n<p><strong>Fields<\/strong> : is the text string between quotes with the field labels that we want to extract from each child document. These labels are of the same type as the Field_list. In this case they can be combined with fixed text as we see in the example:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\"><tt>'Province:&lt; @PRV:Properties:Name&gt; Area m2:&lt; @PRV:Data:Surface&gt; '<\/tt><\/div>\n<p><strong>Separator<\/strong> : is a text string between quotes that will separate the data of each document. You can include \\n for line breaks or \\t for tabs. For example:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\"><tt>'\\n'<\/tt><\/div>\n<p><strong>Order<\/strong> : is an ordering text string. Indicates on which field or fields we want to order the results. The syntax must include the name of one or more fields separated by commas. Behind each of them we can specify the ASC or DESC clause to indicate the order. For example:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\"><tt>'&lt; @PRV:Properties:Name&gt; ASC,&lt; @PRV:Data:Surface&gt; DESC'<\/tt><\/div>\n<p><strong>Condition<\/strong> : This is an optional parameter with a T-SQL condition text string of the same type used in dropdown lists. It allows us to filter the results of the aggregate. For example, to filter <em>Provinces<\/em> starting only with <em>Al<\/em> :<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\"><tt>\"&lt;@PRV:Properties:Name&gt; LIKE 'A%l'\"<\/tt><\/div>\n<p><strong>Top<\/strong>: is an optional parameter with a number indicating the maximum number of records to return.<\/p>\n<p><strong>Grouping<\/strong>: is an optional parameter that indicates the field by which you want to group. When using groupings it is possible to indicate the aggregate functions:<\/p>\n<ul>\n<li>COUNT(*) to return the number of elements<\/li>\n<li>SUM(field) to get the sum of numeric and currency fields<\/li>\n<li>AVG(field) to get the sum of numeric and currency fields<\/li>\n<li>MAX(field) to get the maximum value of the field<\/li>\n<li>MIN(field) to obtain the minimum value of the field<\/li>\n<\/ul>\n<p>It is important to know that when using groupers, only fields that are already included in the <strong>Fields<\/strong> parameter can be used in the <strong>Order<\/strong> parameter.<\/p>\n<p>The <strong>final formula<\/strong> (without grouping) from a field of the <em>Country<\/em> category called <em>Provinces starting with Al and its area <\/em>is as follows:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\"><tt>Document.detailAgg('&lt;@PRV:Data:Country&gt;', 'Province:  &lt;@PRV:Properties:Name&gt;, Area km2: &lt;@PRV:Data:Surface&gt;', '\\n', '&lt;@PRV:Properties:Name&gt;  ASC', \"&lt;@PRV:Properties:Name&gt;  LIKE 'Al%'\")<\/tt><\/div>\n<p>Therefore, for the <em>Country<\/em> Spain, the <em>Provinces that begin with Al field and its area<\/em> would show the following value:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\"><tt>Province: Alava, Surface area km2: 3,037<br \/>\nProvince: Albacete, Area km2: 14.926<br \/>\nProvince: Alicante, Surface km2: 5.817<br \/>\nProvince: Almer\u00eda, Surface area km2: 8.775<\/tt><\/div>\n<p>A variant with groupings of provinces could be as:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\"><tt>Document.detailAgg('&lt;@PRV:Data:Country&gt;', 'Provinces: COUNT(*), Total area: SUM(&lt;PRV:Data:Inhabitants&gt;)', '\\n',null, \"&lt;@PRV:Properties:Name&gt;  LIKE 'Al%'\",null,\"<tt>&lt;@PRV:Properties:Name&gt;<\/tt>\")<\/tt><\/div>\n<p>Therefore, for the <em>Country<\/em> Spain, the <em>Provinces that begin with Al field and its area<\/em> would show the following value:<\/p>\n<div style=\"padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em; font-size: 0.8em;\"><tt>Provinces: 4, Total area: 32.155<\/tt><\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This functionality allows you to compose a field using the data from one or more of its child documents in one of its detail tabs. For example, a document from the Country category has several documents from the Province category associated with it. And if we want to create a&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"content-type":"","footnotes":""},"ht-kb-category":[62],"ht-kb-tag":[83],"class_list":["post-4180","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-functions-javascript","ht_kb_tag-docuo-enterprise"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>detailAgg function - Compose a field from the data of a detail tab - R2 Docuo | Help center<\/title>\n<meta name=\"description\" content=\"This functionality allows you to compose a field using the data from one or more of its child documents in one of its detail tabs.\" \/>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"detailAgg function - Compose a field from the data of a detail tab - R2 Docuo | Help center\" \/>\n<meta property=\"og:description\" content=\"This functionality allows you to compose a field using the data from one or more of its child documents in one of its detail tabs.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/\" \/>\n<meta property=\"og:site_name\" content=\"R2 Docuo | Help center\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-21T11:29:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png\" \/>\n\t<meta property=\"og:image:width\" content=\"845\" \/>\n\t<meta property=\"og:image:height\" content=\"564\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@R2Docuo\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\\\/\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\\\/\",\"name\":\"detailAgg function - Compose a field from the data of a detail tab - R2 Docuo | Help center\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Post-type-Guias-de-usuario.png\",\"datePublished\":\"2021-03-15T18:15:54+00:00\",\"dateModified\":\"2023-11-21T11:29:09+00:00\",\"description\":\"This functionality allows you to compose a field using the data from one or more of its child documents in one of its detail tabs.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\\\/#primaryimage\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Post-type-Guias-de-usuario.png\",\"contentUrl\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/Post-type-Guias-de-usuario.png\",\"width\":845,\"height\":564},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/en\\\/knowledge-base\\\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\\\/\\\/help.r2docuo.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"detailAgg function &#8211; Compose a field from the data of a detail tab\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#website\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/\",\"name\":\"R2 Docuo | Help center\",\"description\":\"Todos los recursos para usuarios, administradores y desarrolladores de de R2 Docuo a tu alcance\",\"publisher\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/help.r2docuo.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#organization\",\"name\":\"R2 Docuo | Help center\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/ILUDEST_CENTRODEAYUDA.png\",\"contentUrl\":\"https:\\\/\\\/help.r2docuo.com\\\/wp-content\\\/uploads\\\/2023\\\/06\\\/ILUDEST_CENTRODEAYUDA.png\",\"width\":1200,\"height\":630,\"caption\":\"R2 Docuo | Help center\"},\"image\":{\"@id\":\"https:\\\/\\\/help.r2docuo.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/R2Docuo\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/r2docuo\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"detailAgg function - Compose a field from the data of a detail tab - R2 Docuo | Help center","description":"This functionality allows you to compose a field using the data from one or more of its child documents in one of its detail tabs.","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"detailAgg function - Compose a field from the data of a detail tab - R2 Docuo | Help center","og_description":"This functionality allows you to compose a field using the data from one or more of its child documents in one of its detail tabs.","og_url":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/","og_site_name":"R2 Docuo | Help center","article_modified_time":"2023-11-21T11:29:09+00:00","og_image":[{"width":845,"height":564,"url":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@R2Docuo","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/","url":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/","name":"detailAgg function - Compose a field from the data of a detail tab - R2 Docuo | Help center","isPartOf":{"@id":"https:\/\/help.r2docuo.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/#primaryimage"},"image":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/#primaryimage"},"thumbnailUrl":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png","datePublished":"2021-03-15T18:15:54+00:00","dateModified":"2023-11-21T11:29:09+00:00","description":"This functionality allows you to compose a field using the data from one or more of its child documents in one of its detail tabs.","breadcrumb":{"@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/#primaryimage","url":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png","contentUrl":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2021\/03\/Post-type-Guias-de-usuario.png","width":845,"height":564},{"@type":"BreadcrumbList","@id":"https:\/\/help.r2docuo.com\/en\/knowledge-base\/detailagg-function-compose-a-field-from-the-data-of-a-detail-tab\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/help.r2docuo.com\/"},{"@type":"ListItem","position":2,"name":"detailAgg function &#8211; Compose a field from the data of a detail tab"}]},{"@type":"WebSite","@id":"https:\/\/help.r2docuo.com\/#website","url":"https:\/\/help.r2docuo.com\/","name":"R2 Docuo | Help center","description":"Todos los recursos para usuarios, administradores y desarrolladores de de R2 Docuo a tu alcance","publisher":{"@id":"https:\/\/help.r2docuo.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/help.r2docuo.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/help.r2docuo.com\/#organization","name":"R2 Docuo | Help center","url":"https:\/\/help.r2docuo.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/help.r2docuo.com\/#\/schema\/logo\/image\/","url":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/06\/ILUDEST_CENTRODEAYUDA.png","contentUrl":"https:\/\/help.r2docuo.com\/wp-content\/uploads\/2023\/06\/ILUDEST_CENTRODEAYUDA.png","width":1200,"height":630,"caption":"R2 Docuo | Help center"},"image":{"@id":"https:\/\/help.r2docuo.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/R2Docuo","https:\/\/www.linkedin.com\/company\/r2docuo"]}]}},"_links":{"self":[{"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb\/4180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/comments?post=4180"}],"version-history":[{"count":0,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb\/4180\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/media\/4053"}],"wp:attachment":[{"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/media?parent=4180"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb-category?post=4180"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/help.r2docuo.com\/en\/wp-json\/wp\/v2\/ht-kb-tag?post=4180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}