{"id":24483,"date":"2024-03-19T15:14:42","date_gmt":"2024-03-19T14:14:42","guid":{"rendered":"https:\/\/developers.ila.cegid.com\/vision\/\/"},"modified":"2025-10-16T10:38:34","modified_gmt":"2025-10-16T09:38:34","slug":"merge-block","status":"publish","type":"vision","link":"https:\/\/developers.ila.cegid.com\/en\/vision\/documentation\/consultations\/article\/merge-block","title":{"rendered":"Merge Block"},"content":{"rendered":"<section class=\"av_textblock_section \"  itemscope=\"itemscope\" itemtype=\"https:\/\/schema.org\/CreativeWork\" ><div class='avia_textblock  '   itemprop=\"text\" ><p>The <strong>Merge<\/strong> block of a Vision query allows to incorporate information from 2 different data sources in the same widget. It is a stage of the query equivalent to a lookup operation (excel, NoSQL) and partly to a join in SQL.<\/p>\n<p>A Vision query proceeds as a succession of individual query blocks, in a main pipe. The merge block allows the establishment of a second auxiliary row, with its own associated data source or dataset, so that the output of this row is combined with the main row at the corresponding query stage. The type of combination of both lines is indicated by the user, establishing the relevant equivalences or association rules between both lines.<\/p>\n<\/div><\/section>\n<section class=\"av_textblock_section \"  itemscope=\"itemscope\" itemtype=\"https:\/\/schema.org\/CreativeWork\" ><div class='avia_textblock  '   itemprop=\"text\" ><h2>Example<\/h2>\n<p>A typical example helps to understand in a simple way what a merge block does:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-24666 aligncenter\" src=\"https:\/\/developers.ila.cegid.com\/wp-content\/uploads\/Combinar-Bloque.png\" alt=\"\" width=\"700\" height=\"386\" srcset=\"https:\/\/developers.ila.cegid.com\/wp-content\/uploads\/Combinar-Bloque.png 1972w, https:\/\/developers.ila.cegid.com\/wp-content\/uploads\/Combinar-Bloque-300x166.png 300w, https:\/\/developers.ila.cegid.com\/wp-content\/uploads\/Combinar-Bloque-1030x568.png 1030w, https:\/\/developers.ila.cegid.com\/wp-content\/uploads\/Combinar-Bloque-768x424.png 768w, https:\/\/developers.ila.cegid.com\/wp-content\/uploads\/Combinar-Bloque-1536x847.png 1536w, https:\/\/developers.ila.cegid.com\/wp-content\/uploads\/Combinar-Bloque-1500x828.png 1500w, https:\/\/developers.ila.cegid.com\/wp-content\/uploads\/Combinar-Bloque-705x389.png 705w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<\/div><\/section>\n<section class=\"av_textblock_section \"  itemscope=\"itemscope\" itemtype=\"https:\/\/schema.org\/CreativeWork\" ><div class='avia_textblock  '   itemprop=\"text\" ><ol>\n<li>A query has as its main line data from dataset A, which includes the customer ID and associated sales. The customer ID is a useful field for efficient storage of information, but it does not provide information to a user viewing data. It is normal to want to decode that ID.<\/li>\n<li>A second dataset B has the equivalences between customer ID and its associated sales agent. A secondary query is defined with data source dataset B, and that combines with the main line by the customer ID field. Therefore, for each customer ID in the main line, its agent is searched for using the secondary line.<\/li>\n<li>The result of the merge block will therefore be 3 fields: the customer ID and the associated sales, which come from the main line, and the sales agent, which come from the sub-line.<\/li>\n<\/ol>\n<\/div><\/section>\n<div  class='avia-video avia-video-16-9 avia-video-html5  '   itemprop=\"video\" itemtype=\"https:\/\/schema.org\/VideoObject\"  data-original_url='https:\/\/helpcenter.ila.cegid.com\/wp-content\/uploads\/app.widget.consulta.combinar-rellenar.bloque-1.mp4' ><video class='avia_video'    preload=\"auto\"  controls id='player_24483_1521990726_1896576076'><source src=\"https:\/\/helpcenter.ila.cegid.com\/wp-content\/uploads\/app.widget.consulta.combinar-rellenar.bloque-1.mp4\" type=\"video\/mp4\" \/><\/video><\/div>\n<section class=\"av_textblock_section \"  itemscope=\"itemscope\" itemtype=\"https:\/\/schema.org\/CreativeWork\" ><div class='avia_textblock  '   itemprop=\"text\" ><h2 id=\"particularidades-del-bloque-combinar\">Particularities of the Merge Block<a class=\"anchor\" href=\"#funcionamiento-y-eficiencia\" name=\"funcionamiento-y-eficiencia\"><\/a><\/h2>\n<p>This block is potentially dangerous, since the combination of 2 data sets can generate an intermediate data set so large that its management consumes the available computational resources, as, for example, happens with joins in SQL.<br \/>\nTherefore, it is very important to be clear about how the merge block is computationally solved:<\/p>\n<ul>\n<li>The block preceding the merge block determines the main row data to be combined: N rows of data.<\/li>\n<li>For each row or data record of the main row, the query of the child row is executed: N queries are therefore resolved sequentially, with a consequent impact on the performance of the overall query. Unlike what sometimes happens with SQL queries, there is no &#8220;optimization&#8221; of the query: repeated combinations or equivalences are not grouped or associated with possible indexes to execute the combined query more efficiently.<\/li>\n<li>Each record in the main row passes to its child query the specific values of the equivalence fields. These values are initially included as a filter in the executed secondary query: the secondary query thus works on a subset of the secondary dataset and not on the total.<\/li>\n<li>The secondary query is executed, and may return:\n<ul>\n<li><strong>No record<\/strong>: in that case the original record of the main row is reported with empty child row fields in case the equivalence type is left join, or discarded (i.e. not returned) in case the type is inner join.<\/li>\n<li><strong><code>1<\/code> <\/strong><strong>record<\/strong><strong>:<\/strong> the original record of the main row plus the fields of the child row obtained at the end of the query are returned<\/li>\n<li><strong><code>m<\/code><\/strong><strong>records<\/strong><strong>:<\/strong> <code>m<\/code> records are returned where the values of the fields of the main line are always the same, and those of the secondary line are those corresponding to their corresponding secondary record.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/div><\/section>\n<section class=\"av_textblock_section \"  itemscope=\"itemscope\" itemtype=\"https:\/\/schema.org\/CreativeWork\" ><div class='avia_textblock  '   itemprop=\"text\" ><h2 id=\"otras-particularidades\">Other Particularities<\/h2>\n<ul>\n<li><strong>Filters and dependencies in the block<\/strong>. The selector filters of the tab where the widget with merge block is placed affect\/do not affect both the dataset of the main line and the dataset of the secondary line, i.e., they are not allowed to affect one line but not the other. It is important to note that a filter associated to a field that is not in a dataset does not affect the query that has that dataset as data source, so it can happen that a filter affects the main line but not the secondary line, and vice versa.<\/li>\n<li><strong>Same data source in main and secondary.<\/strong> It is possible to use the same dataset of the main line as the data source of the secondary line. Therefore, the result of a merge block may return duplicate fields, i.e. they are in both rows. To avoid such duplicity, the fields of the main dataset are prioritized, i.e. in case the same field is in both rows, the duplicate field is discarded from the secondary row contribution.<br \/>\n<strong>Note<\/strong>: If both fields are needed, it is the user who must disambiguate: simply create a new &#8220;alias&#8221;, i.e. a formula field equal to the original field in one of the lines, and disable the original field.<\/li>\n<li><strong>Formulas<\/strong>. It is possible to define formulas in both the main and sub-line queries. It is important to correctly manage dependencies in the sub-line formulas, because if they are not explicitly enabled at the end of the combine block, they will be added automatically (and if a grouping criterion needs to be applied, this is the <em>sum<\/em> function for measures and the <em>first<\/em> function for dimensions).<\/li>\n<\/ul>\n<\/div><\/section>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1972,"featured_media":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","tags":[725],"post-type":[300],"categoria-vision":[724],"class_list":["post-24483","vision","type-vision","status-publish","format-standard","hentry","tag-merge","post-type-artigo","categoria-vision-consultations"],"_links":{"self":[{"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/vision\/24483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/vision"}],"about":[{"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/types\/vision"}],"author":[{"embeddable":true,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/users\/1972"}],"replies":[{"embeddable":true,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/comments?post=24483"}],"version-history":[{"count":0,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/vision\/24483\/revisions"}],"wp:attachment":[{"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/media?parent=24483"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/tags?post=24483"},{"taxonomy":"post-type","embeddable":true,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/post-type?post=24483"},{"taxonomy":"categoria-vision","embeddable":true,"href":"https:\/\/developers.ila.cegid.com\/en\/wp-json\/wp\/v2\/categoria-vision?post=24483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}