{"id":1807,"date":"2020-10-30T10:26:08","date_gmt":"2020-10-30T10:26:08","guid":{"rendered":"https:\/\/bi.unija.com\/en\/?p=1807"},"modified":"2020-11-27T11:39:46","modified_gmt":"2020-11-27T11:39:46","slug":"dax-function-filter","status":"publish","type":"post","link":"https:\/\/bi.unija.com\/en\/dax-function-filter\/","title":{"rendered":"DAX function FILTER"},"content":{"rendered":"<p><em>For Power BI version 2.76.5678.782 (December 2019).<\/em><\/p>\n<p><strong>FILTER()<\/strong> is a function that filters a table and returns the remaining rows. It is similar to function <strong>CALCULATE()<\/strong>. The difference is <strong>FILTER() <\/strong>returns a filtered table and <strong>CALCULATE()<\/strong> returns value of the expression for the filtered table. <strong>CALCULATE() <\/strong>is used with simple filters, for example comparing values in the column to a specified value. We commonly use <strong>FILTER() <\/strong>function in the <strong>CALCULATE() <\/strong>function to create complex filters.<\/p>\n<p>You can find more on <strong>CALCULATE()<\/strong> function in article <a href=\"https:\/\/bi.unija.com\/en\/dax-function-calculate\/\">DAX function CALCULATE<\/a>.<\/p>\n<h1>Syntax<\/h1>\n<p>FILTER (Table, Filter)<\/p>\n<table>\n<tbody>\n<tr>\n<td>Parameter<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td>Table<\/td>\n<td>Table to be filtered<\/td>\n<\/tr>\n<tr>\n<td>Filter<\/td>\n<td>Filter<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>Example: filtering a table<\/h1>\n<p>We have current storage of office supplies in our <strong>Supplies<\/strong> table.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"184\" height=\"171\" class=\"wp-image-1808\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/word-image-11.png\" \/><\/p>\n<p>We want to filter out <strong>Paper clips<\/strong>. We follow the steps bellow.<\/p>\n<p>1. We don&#8217;t want to create a new measure because measures are used to return a single value. Instead, we create a calculated table using <strong>New table<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"351\" height=\"104\" class=\"wp-image-1809\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/word-image-12.png\" srcset=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/word-image-12.png 351w, https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/word-image-12-300x89.png 300w\" sizes=\"(max-width: 351px) 100vw, 351px\" \/><\/p>\n<p>2. We enter the following formula.<\/p>\n<p>FILTER_Example = FILTER(Supplies, Supplies[Name] &lt;&gt; &#8220;Paper clips&#8221;)<\/p>\n<p>3. We get a filtered table.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"683\" height=\"183\" class=\"wp-image-1810\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/word-image-13.png\" srcset=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/word-image-13.png 683w, https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/word-image-13-300x80.png 300w\" sizes=\"(max-width: 683px) 100vw, 683px\" \/><\/p>\n<h1>Example: counting rows with FILTER() or CALCULATE()<\/h1>\n<p>We can count rows using <strong>FILTER() <\/strong>and <strong>CALCULATE()<\/strong> functions. Let&#8217;s again use table of office supplies <strong>Supplies<\/strong>. We want to know how many articles we have without the article <strong>Paper clips<\/strong>. We create measures using following formulas.<\/p>\n<p>FILTER_Example = COUNTROWS(FILTER(Supplies, Supplies[Name] &lt;&gt; &#8220;Paper clips&#8221;))<\/p>\n<p>CALCULATE_Example = CALCULATE(COUNTROWS(Supplies), Supplies[Name] &lt;&gt; &#8220;Paper clips&#8221;)<\/p>\n<p>In both cases formula is executed by the following steps.<\/p>\n<ol>\n<li>Table <strong>Supplies <\/strong>is filtered, leaving only rows that don&#8217;t have value <strong>Paper clips<\/strong> in <strong>Name<\/strong> column.<\/li>\n<li>Rows are counted in the filtered table.<\/li>\n<\/ol>\n<p>We use Table visualization to check the values measures return. We see the result is the same in both cases.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"262\" height=\"60\" class=\"wp-image-1811\" src=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/word-image-14.png\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For Power BI version 2.76.5678.782 (December 2019). FILTER() is a function that filters a table and returns the remaining rows. It is similar to function CALCULATE(). The difference is FILTER() returns a filtered table and CALCULATE() returns value of the<\/p>\n","protected":false},"author":5,"featured_media":1812,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[5,8],"class_list":["post-1807","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-intermediate","tag-dax","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>DAX function FILTER - 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\/dax-function-filter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"DAX function FILTER - Bi Unija\" \/>\n<meta property=\"og:description\" content=\"For Power BI version 2.76.5678.782 (December 2019). FILTER() is a function that filters a table and returns the remaining rows. It is similar to function CALCULATE(). The difference is FILTER() returns a filtered table and CALCULATE() returns value of the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bi.unija.com\/en\/dax-function-filter\/\" \/>\n<meta property=\"og:site_name\" content=\"Bi Unija\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-30T10:26:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-27T11:39:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/30.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=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/bi.unija.com\/en\/dax-function-filter\/\",\"url\":\"https:\/\/bi.unija.com\/en\/dax-function-filter\/\",\"name\":\"DAX function FILTER - Bi Unija\",\"isPartOf\":{\"@id\":\"https:\/\/bi.unija.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/bi.unija.com\/en\/dax-function-filter\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/bi.unija.com\/en\/dax-function-filter\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/30.png\",\"datePublished\":\"2020-10-30T10:26:08+00:00\",\"dateModified\":\"2020-11-27T11:39:46+00:00\",\"author\":{\"@id\":\"https:\/\/bi.unija.com\/en\/#\/schema\/person\/3bed36623727c7162e421c4366a54e10\"},\"breadcrumb\":{\"@id\":\"https:\/\/bi.unija.com\/en\/dax-function-filter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/bi.unija.com\/en\/dax-function-filter\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bi.unija.com\/en\/dax-function-filter\/#primaryimage\",\"url\":\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/30.png\",\"contentUrl\":\"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/30.png\",\"width\":720,\"height\":480},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/bi.unija.com\/en\/dax-function-filter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/bi.unija.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DAX function FILTER\"}]},{\"@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":"DAX function FILTER - 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\/dax-function-filter\/","og_locale":"en_US","og_type":"article","og_title":"DAX function FILTER - Bi Unija","og_description":"For Power BI version 2.76.5678.782 (December 2019). FILTER() is a function that filters a table and returns the remaining rows. It is similar to function CALCULATE(). The difference is FILTER() returns a filtered table and CALCULATE() returns value of the","og_url":"https:\/\/bi.unija.com\/en\/dax-function-filter\/","og_site_name":"Bi Unija","article_published_time":"2020-10-30T10:26:08+00:00","article_modified_time":"2020-11-27T11:39:46+00:00","og_image":[{"width":720,"height":480,"url":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/30.png","type":"image\/png"}],"author":"Branka Trifunovi\u0107","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Branka Trifunovi\u0107","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/bi.unija.com\/en\/dax-function-filter\/","url":"https:\/\/bi.unija.com\/en\/dax-function-filter\/","name":"DAX function FILTER - Bi Unija","isPartOf":{"@id":"https:\/\/bi.unija.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/bi.unija.com\/en\/dax-function-filter\/#primaryimage"},"image":{"@id":"https:\/\/bi.unija.com\/en\/dax-function-filter\/#primaryimage"},"thumbnailUrl":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/30.png","datePublished":"2020-10-30T10:26:08+00:00","dateModified":"2020-11-27T11:39:46+00:00","author":{"@id":"https:\/\/bi.unija.com\/en\/#\/schema\/person\/3bed36623727c7162e421c4366a54e10"},"breadcrumb":{"@id":"https:\/\/bi.unija.com\/en\/dax-function-filter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bi.unija.com\/en\/dax-function-filter\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bi.unija.com\/en\/dax-function-filter\/#primaryimage","url":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/30.png","contentUrl":"https:\/\/bi.unija.com\/en\/wp-content\/uploads\/sites\/2\/2020\/10\/30.png","width":720,"height":480},{"@type":"BreadcrumbList","@id":"https:\/\/bi.unija.com\/en\/dax-function-filter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/bi.unija.com\/en\/"},{"@type":"ListItem","position":2,"name":"DAX function FILTER"}]},{"@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\/1807"}],"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=1807"}],"version-history":[{"count":3,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/posts\/1807\/revisions"}],"predecessor-version":[{"id":1816,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/posts\/1807\/revisions\/1816"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/media\/1812"}],"wp:attachment":[{"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/media?parent=1807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/categories?post=1807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bi.unija.com\/en\/wp-json\/wp\/v2\/tags?post=1807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}