{"id":1753,"date":"2020-09-18T06:39:10","date_gmt":"2020-09-18T06:39:10","guid":{"rendered":"https:\/\/bi.unija.com\/en\/?p=1753"},"modified":"2020-11-27T12:57:58","modified_gmt":"2020-11-27T12:57:58","slug":"row-context-in-power-bi","status":"publish","type":"post","link":"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/","title":{"rendered":"Row Context in Power BI"},"content":{"rendered":"<p><em>For Power BI version 2.76.5678.782 (December 2019).<\/em><\/p>\n<p>Row context is a property of calculated columns and some functions of being aware of rows within calculations. Row context means that the function <em>travels through every row separately<\/em>. Expression is calculated for each row and then aggregated into final result.<\/p>\n<p>Row context exists in:<\/p>\n<ul>\n<li>X-functions, for example <strong>SUMX()<\/strong>, <strong>AVERAGEX()<\/strong><\/li>\n<li>Function <strong>FILTER()<\/strong><\/li>\n<li>Calculated rows<\/li>\n<\/ul>\n<p>Let&#8217;s look at an example using function <strong>SUMX<\/strong>, shown in the image below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"411\" height=\"79\" class=\"wp-image-1754\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/word-image-16.png\" srcset=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/word-image-16.png 411w, https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/word-image-16-300x58.png 300w\" sizes=\"(max-width: 411px) 100vw, 411px\" \/><\/p>\n<p>Function <strong>SUMX()<\/strong> creates a row context in table <strong>Sales<\/strong> (#1). It then iterates through table, row by row. In each row it takes the value of fields <strong>Price<\/strong> (#2) and <strong>Tax<\/strong> (#3) and adds them up. At the end it adds up all the results into one final result.<\/p>\n<h1>Row context in calculated columns<\/h1>\n<p>Calculated columns also have the property of row context. Expression is calculated for every row and saved to every cell separately. Main difference between X functions and calculated columns is precisely that X functions don&#8217;t save intermediate result and calculated columns do. This is the reason we avoid calculated columns, saving intermediate results can occupy a lot of memory and slow down the model.<\/p>\n<h1>Row context doesn&#8217;t always create filter context<\/h1>\n<p>In Filter Context in Power BI article we saw how filter context works. It is important to understand that row context doesn&#8217;t always create filter context. Additionally, row context doesn&#8217;t flow through connections. Let&#8217;s look what this means through example.<\/p>\n<p>We&#8217;ll add calculated column to <strong>Products<\/strong> table:<strong> TotalSales = SUM(Sales[Value]).<\/strong><\/p>\n<p>Column will add up all the values in <strong>Value<\/strong> column in the <strong>Sales<\/strong> table. What do we expect as result? Will value for each product differ? The answer is no, the value will be the same for all rows.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"492\" class=\"wp-image-1755\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/word-image-17.png\" srcset=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/word-image-17.png 651w, https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/word-image-17-300x227.png 300w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/p>\n<p>The reason is that row context doesn&#8217;t always create filter context. Value is indeed calculated for each row separately, but product in <strong>Game &amp; Platform<\/strong> row can&#8217;t filter <strong>Sales<\/strong> table. Table remains unfiltered and result is the same for each row.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For Power BI version 2.76.5678.782 (December 2019). Row context is a property of calculated columns and some functions of being aware of rows within calculations. Row context means that the function travels through every row separately. Expression is calculated for<\/p>\n","protected":false},"author":5,"featured_media":1756,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[8],"class_list":["post-1753","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-advanced","tag-power-bi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Row Context in Power BI - Bi Unija<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Row Context in Power BI - Bi Unija\" \/>\n<meta property=\"og:description\" content=\"For Power BI version 2.76.5678.782 (December 2019). Row context is a property of calculated columns and some functions of being aware of rows within calculations. Row context means that the function travels through every row separately. Expression is calculated for\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/\" \/>\n<meta property=\"og:site_name\" content=\"Bi Unija\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-18T06:39:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-27T12:57:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/25eng.png\" \/>\n\t<meta property=\"og:image:width\" content=\"720\" \/>\n\t<meta property=\"og:image:height\" content=\"480\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Branka Trifunovi\u0107\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Branka Trifunovi\u0107\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/\",\"url\":\"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/\",\"name\":\"Row Context in Power BI - Bi Unija\",\"isPartOf\":{\"@id\":\"https:\/\/bi.unija.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/25eng.png\",\"datePublished\":\"2020-09-18T06:39:10+00:00\",\"dateModified\":\"2020-11-27T12:57:58+00:00\",\"author\":{\"@id\":\"https:\/\/bi.unija.com\/en\/#\/schema\/person\/3bed36623727c7162e421c4366a54e10\"},\"breadcrumb\":{\"@id\":\"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/#primaryimage\",\"url\":\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/25eng.png\",\"contentUrl\":\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/25eng.png\",\"width\":720,\"height\":480},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/bi.unija.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Row Context in Power BI\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/bi.unija.com\/en\/#website\",\"url\":\"https:\/\/bi.unija.com\/en\/\",\"name\":\"Bi Unija\",\"description\":\"Just another Bi site\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/bi.unija.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/bi.unija.com\/en\/#\/schema\/person\/3bed36623727c7162e421c4366a54e10\",\"name\":\"Branka Trifunovi\u0107\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bi.unija.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ec99f651bcc98a163161515ec254b974?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ec99f651bcc98a163161515ec254b974?s=96&d=mm&r=g\",\"caption\":\"Branka Trifunovi\u0107\"},\"url\":\"https:\/\/bi.unija.com\/en\/author\/branka\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Row Context in Power BI - Bi Unija","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/","og_locale":"en_US","og_type":"article","og_title":"Row Context in Power BI - Bi Unija","og_description":"For Power BI version 2.76.5678.782 (December 2019). Row context is a property of calculated columns and some functions of being aware of rows within calculations. Row context means that the function travels through every row separately. Expression is calculated for","og_url":"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/","og_site_name":"Bi Unija","article_published_time":"2020-09-18T06:39:10+00:00","article_modified_time":"2020-11-27T12:57:58+00:00","og_image":[{"width":720,"height":480,"url":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/25eng.png","type":"image\/png"}],"author":"Branka Trifunovi\u0107","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Branka Trifunovi\u0107","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/","url":"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/","name":"Row Context in Power BI - Bi Unija","isPartOf":{"@id":"https:\/\/bi.unija.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/#primaryimage"},"image":{"@id":"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/#primaryimage"},"thumbnailUrl":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/25eng.png","datePublished":"2020-09-18T06:39:10+00:00","dateModified":"2020-11-27T12:57:58+00:00","author":{"@id":"https:\/\/bi.unija.com\/en\/#\/schema\/person\/3bed36623727c7162e421c4366a54e10"},"breadcrumb":{"@id":"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/#primaryimage","url":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/25eng.png","contentUrl":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/09\/25eng.png","width":720,"height":480},{"@type":"BreadcrumbList","@id":"https:\/\/bi.unija.com\/en\/row-context-in-power-bi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/bi.unija.com\/en\/"},{"@type":"ListItem","position":2,"name":"Row Context in Power BI"}]},{"@type":"WebSite","@id":"https:\/\/bi.unija.com\/en\/#website","url":"https:\/\/bi.unija.com\/en\/","name":"Bi Unija","description":"Just another Bi site","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bi.unija.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/bi.unija.com\/en\/#\/schema\/person\/3bed36623727c7162e421c4366a54e10","name":"Branka Trifunovi\u0107","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bi.unija.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ec99f651bcc98a163161515ec254b974?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ec99f651bcc98a163161515ec254b974?s=96&d=mm&r=g","caption":"Branka Trifunovi\u0107"},"url":"https:\/\/bi.unija.com\/en\/author\/branka\/"}]}},"_links":{"self":[{"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/posts\/1753"}],"collection":[{"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/comments?post=1753"}],"version-history":[{"count":1,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/posts\/1753\/revisions"}],"predecessor-version":[{"id":1757,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/posts\/1753\/revisions\/1757"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/media\/1756"}],"wp:attachment":[{"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/media?parent=1753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/categories?post=1753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/tags?post=1753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}