{"id":93031,"date":"2021-12-17T15:50:13","date_gmt":"2021-12-17T15:50:13","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=93031"},"modified":"2026-03-06T14:14:58","modified_gmt":"2026-03-06T14:14:58","slug":"how-to-filter-dax-for-paginated-reports","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/how-to-filter-dax-for-paginated-reports\/","title":{"rendered":"DAX Filtering for Paginated Reports: A Guide"},"content":{"rendered":"\n<p>DAX filtering in paginated reports works differently from SQL &#8211; you can&#8217;t simply add a WHERE clause. Instead, use the SUMMARIZECOLUMNS function with filter arguments to control what data appears in your paginated report output. This article covers the complete filtering workflow: basic column filtering, OR logic (which requires special handling in DAX), calculated filter expressions, and the rscustomdaxfilter parameter technique for passing user selections from Report Builder into your DAX queries. All examples use the Power BI Premium service with paginated reports.<\/p>\n\n\n<p><strong>The series so far:<\/strong><\/p>\n<ol>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/introduction-to-dax-for-paginated-reports\/\">Introduction to DAX for paginated reports<\/a><\/li>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/how-to-filter-dax-for-paginated-reports\/\">How to filter DAX for paginated reports<\/a><\/li>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/dax-table-functions-for-paginated-reports-part-1\/\"> \u00a0DAX table functions for paginated reports: Part 1<\/a><\/li>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/dax-table-functions-for-paginated-reports-part-2\/\">DAX table functions for paginated reports: Part 2<\/a><\/li>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/tips-and-tricks-with-dax-table-functions-in-paginated-reports\/\">Tips and tricks with DAX table functions in paginated reports<\/a><\/li>\n<\/ol>\n\n\n\n\n<p>In the <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/introduction-to-dax-for-paginated-reports\/\">previous article<\/a> of this short series, you learned the fundamentals of creating datasets using DAX to populate paginated reports delivered using the Power BI Premium service. The next step is to appreciate the practicalities \u2013 and subtleties \u2013 of how data can be filtered using DAX for paginated report output.<\/p>\n\n\n\n<p>As most, if not all, report developers come from an SQL background, it may seem overkill to devote an entire article to filtering data. However, DAX is very unlike SQL as far as filtering output data is concerned. Something as simple as classic OR logic needs to be handled differently from the techniques you may be used to \u2013 either as a SQL or as a Power BI developer. To ensure that you can deliver the report data that you need to populate paginated reports, take a detailed look at how to filter data in DAX datasets using the core <code>SUMMARIZECOLUMNS()<\/code> function.<\/p>\n\n\n\n<p>Like all the articles in this series, this article uses a sample dataset named <a href=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/11\/CarsDataWarehouse.pbix\"><em>CarsDataWarehouse.Pbix<\/em><\/a> that you can download and use as the basis for practicing and testing DAX data output techniques. If you wish to understand the dataset structure, please refer to the first article in the series.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-basic-data-output-to-ssrs-using-summarizecolumns\">Basic Data Output to SSRS Using SUMMARIZECOLUMNS()<\/h2>\n\n\n\n<p>One positive thing that I can say about the Power BI Report Builder Query Designer is that it introduces you to the core DAX function that you are likely to use when developing DAX queries for paginated reports: <code>SUMMARIZECOLUMNS()<\/code>.<\/p>\n\n\n\n<p><code>SUMMARIZECOLUMNS()<\/code> is probably the DAX function that most people generally use to produce tables of data &#8211; which makes it an ideal function to query Power BI dataset data for SSRS reports. By a happy coincidence, Report Builder also uses the function to generate DAX. Consequently, it is the default option for report developers who need to use DAX data sources.<\/p>\n\n\n\n<p><code>SUMMARIZECOLUMNS()<\/code> is so powerful because it allows you to assemble, filter, and aggregate data from a Power BI dataset into a single tabular output for paginated reports. Indeed, it requires that you apply these elements in a specific order inside the <code>SUMMARIZECOLUMNS()<\/code> function:<\/p>\n\n\n<div class=\"block-core-list\">\n<ol class=\"wp-block-list\">\n<li>A list of fields from the data model<\/li>\n\n\n\n<li>Any required Filters<\/li>\n\n\n\n<li>Any required Aggregations<\/li>\n<\/ol>\n<\/div>\n\n\n<p>It is worth noting that parts (2) &amp; (3) in this list are optional. You do not have to filter data or add aggregations and can simply use <code>SUMMARIZECOLUMNS()<\/code> to output the list of data you need. This means that any of the following approaches will work.<\/p>\n\n\n\n<p><strong>Read also:<\/strong><br><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/reporting-services-basics-overview-and-installation\/\" target=\"_blank\" rel=\"noreferrer noopener\">SSRS basics and overview<\/a><br><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/insights-from-the-ssrs-database\/\" target=\"_blank\" rel=\"noreferrer noopener\">Insights from the SSRS database<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-column-list-only\">Column List Only<\/h3>\n\n\n\n<p>Suppose all you want to do is return a list of columns to a paginated report. In that case, you can manually write code like the following DAX snippet developed in DAX Studio that you then test and subsequently copy and paste into Power BI Report Builder. Of course, when I say \u201cmanually\u201d write code, I mean search for the fields, drag and drop them into the query pane, and use autocomplete to enter any DAX keywords.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\n&nbsp;DimVehicle[Make]\n,DimVehicle[Model]\n)<\/pre>\n\n\n\n<p>The output from this short piece of DAX is (in a shortened form):<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"134\" height=\"180\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-2.png\" alt=\"\" class=\"wp-image-93032\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>While looking at core DAX for report output, it is perhaps worth a quick detour to explain the <code>EVALUATE<\/code> function. This function is the DAX statement needed to execute a query and return data. In simple DAX queries, all that you need to do is to start the query with the keyword <code>EVALUATE<\/code>. As queries become more intricate (and as you will discover in the course of these four articles), this initial approach can be extended to handle more complex requirements.<\/p>\n\n\n\n<p>There are a couple of points that it is worth noting at this juncture:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li><code>SUMMARIZECOLUMNS()<\/code> can return data from all the tables in the underlying dataset.<\/li>\n\n\n\n<li>A well thought out data model is a fundamental prerequisite.<\/li>\n\n\n\n<li>All field references must be fully qualified (table and column name).<\/li>\n<\/ul>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-column-list-and-expressions\">Column list and Expressions<\/h3>\n\n\n\n<p>If you need to output not only a set of columnar data but also add some DAX calculations (which includes any measures in the underlying dataset), you will need to write code like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\n&nbsp;DimVehicle[Make]\n,DimVehicle[Model]\n,\"Total Additional Costs\"\n, SUM(FactSales[Total Additional Costs])\n,\"Gross Profit\", [Gross Profit]\n,\"Average Cost\", AVERAGE(FactSales[CostPrice])\n,\"Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>The shortened output from this piece of DAX is ideally suited to a paginated report table:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"505\" height=\"251\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-3.png\" alt=\"\" class=\"wp-image-93033\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>It is important in this case to respect the following constraints:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>Always place DAX calculations (which includes measures already in the dataset) <strong>after<\/strong> \u201cplain\u201d data columns.<\/li>\n\n\n\n<li>Calculated <strong>columns<\/strong> in the source data (such as the field \u201cTotal Additional Costs\u201d in this example) are considered to be data columns. As such, they do not need a specific column name added (as is the case for measures). However, they do need an aggregation function applied.<\/li>\n\n\n\n<li>Expressions can be measures in the underlying dataset (like the measure \u201cGross Profit\u201d in this example) or specific DAX calculations \u2013 such as the measure \u201cAverage Cost\u201d in this example.<\/li>\n\n\n\n<li>You have to add a name for each calculation or measure before the measure or calculation itself. This name will become the basis for the name used in the output for the respective column.<\/li>\n\n\n\n<li>Measure\/calculation names must be entered in double quotes and separated from the actual measure or calculation by a comma.<\/li>\n\n\n\n<li>Measures (such as [Gross Profit] in the previous code snippet) do <strong>not<\/strong> need to be fully qualified. Nor \u2013 as they are measures \u2013 do they need an aggregation function applied.<\/li>\n\n\n\n<li>You can mix measures from the dataset with calculations in any order provided that they follow the definition of standard data columns. That is, they must appear after the columns that are extracted.<\/li>\n<\/ul>\n<\/div>\n\n\n<p>The calculations can, of course, get much more complex than these simple examples.<\/p>\n\n\n\n<p><strong>Note:<\/strong><\/p>\n\n\n\n<p>The output shown is from DAX Studio. If you use Power BI Report Builder to test the DAX you will notice that the column names are changed in the output and any calculations are preceded by ID_ &#8211; as shown in the following figure:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"234\" height=\"140\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-4.png\" alt=\"\" class=\"wp-image-93034\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-column-list-and-filter\">Column list and Filter<\/h3>\n\n\n\n<p><code>SUMMARIZECOLUMNS()<\/code> also lets you add filters to reduce the number of records output to SSRS. You can see a simple example in the following code snippet:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\n&nbsp;DimVehicle[Make]\n,DimVehicle[Model]\n,DimGeography[CountryName]\n,FILTER(\n        VALUES(DimGeography[CountryName])\n        ,DimGeography[CountryName] = \"France\")\n,\"Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>The shortened output from this piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"265\" height=\"252\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-5.png\" alt=\"\" class=\"wp-image-93035\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>The points of note in this simple example are:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>Any filters have to be added <strong>after<\/strong> columns of data and <strong>before<\/strong> the measures or calculations.<\/li>\n\n\n\n<li>Simple filters use the <code>FILTER()<\/code> function and specify:<\/li>\n\n\n\n<li>A table to filter (<code>VALUES()<\/code> is used to return a unique list of elements)<\/li>\n\n\n\n<li>The expression to be evaluated for each row of the table must equate to True or False for each row.<\/li>\n<\/ul>\n<\/div>\n\n\n<p>You do not need to output any columns used to filter data. I added the <code>CountryName<\/code> column in this code snippet only to show that the filter was working.<\/p>\n\n\n\n<p><strong>Read also:<\/strong><br><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/using-the-dax-calculate-and-values-functions\/\" target=\"_blank\" rel=\"noreferrer noopener\">How the DAX CALCULATE function works<\/a><br><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/bi-sql-server\/using-calendars-and-dates-in-power-bi\/\" target=\"_blank\" rel=\"noreferrer noopener\">Calendar tables and dates in Power BI<\/a><br><a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/using-a-subquery-in-a-select-statement\/\" target=\"_blank\" rel=\"noreferrer noopener\">Subqueries in SQL for data preparation<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-column-list-filter-and-aggregation\">Column List, Filter and Aggregation<\/h3>\n\n\n\n<p>Finally, columns, filters and expressions can be combined in a SUMMARIZECOLUMNS() expression like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\n&nbsp;DimVehicle[Make]     \/\/ Data (Column)\n,DimVehicle[Model]    \/\/ Data (Column)\n,DimGeography[CountryName]\n,FILTER(\n        VALUES(DimGeography[CountryName])\n        ,DimGeography[CountryName] = \"France\")  \/\/ Filter\n,\"Sales\", SUM(FactSales[SalePrice])   \/\/ Calculation\n,\"Average Cost\", AVERAGE(FactSales[CostPrice]) \/\/ Calculation\n,\"Profit\", [Gross Profit]   \/\/  Measure\n)<\/pre>\n\n\n\n<p>The shortened output from this piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"384\" height=\"274\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-6.png\" alt=\"\" class=\"wp-image-93036\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>The key takeaway here is to respect the order of the three parts of the full <code>SUMMARIZECOLUMNS()<\/code> expression:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>Firstly \u2013 the columns of data you wish to return to SSRS.<\/li>\n\n\n\n<li>Secondly \u2013 Any filters<\/li>\n\n\n\n<li>Thirdly \u2013 Any expressions (measures from the dataset or calculations)<\/li>\n<\/ul>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-filtering-approaches\">Filtering Approaches<\/h2>\n\n\n\n<p>Assembling output \u2013 directly from columns, existing metrics, or DAX calculations \u2013 is nearly always the easy part. Filtering the source data so that you only see exactly what you want and need is frequently where the challenges lie. This is often the case if you are new to DAX.<\/p>\n\n\n\n<p>Consequently, the next thing to look at in greater depth is how to filter data in more complex ways inside the <code>SUMMARIZECOLUMNS()<\/code> function.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-elementary-and-logic\">Elementary AND logic<\/h3>\n\n\n\n<p>It is worth noting that, inside the <code>SUMMARIZECOLUMNS() <\/code>function, all filters are logical <code>AND<\/code> filters \u2013 so the following DAX query returns cars sold in France that are black:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\n&nbsp;DimVehicle[Make]\n,DimVehicle[Model]\n,DimVehicle[Color]\n,DimGeography[CountryName]\n,FILTER(\n        VALUES(DimGeography[CountryName])\n        ,DimGeography[CountryName] = \"France\")\n,FILTER(\n        VALUES(DimVehicle[Color])\n        ,DimVehicle[Color] = \"Black\")\n,\"Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>The shortened output from this piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"325\" height=\"221\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-7.png\" alt=\"\" class=\"wp-image-93037\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>You do not need to add an <code>AND<\/code> keyword anywhere inside the DAX. Merely having two filters creates a \u201clogical AND\u201d clause. It is also worth remembering that you can add any number of filters in this way. It is also worth noting that you do not have to add the fields used in the <code>FILTER()<\/code> function to the output \u2013 I am doing this here simply to show that the filter works.<\/p>\n\n\n\n<p><strong>Note:<\/strong><\/p>\n\n\n\n<p>I am including the filter columns in the output so that it is clear that the filters work. Obviously, this affects the aggregated output. So I want to make it clear that this is not necessary (rather like you do not have to place any fields used in a SQL <code>WHERE<\/code> clause in the <code>SELECT<\/code> clause) and is only done here to show that the filter works.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-elementary-or-logic\">Elementary OR logic<\/h3>\n\n\n\n<p>OR logic can be slightly more challenging in DAX, depending on the complexity of the query requirement. If all you want to do is to filter between only two alternatives for the same field, then there is a simple solution \u2013 the DAX <code>OR()<\/code> clause, applied like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\n&nbsp;DimVehicle[Make]\n,DimVehicle[Model]\n,DimVehicle[Color]\n\n,FILTER(\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VALUES(DimVehicle[Color])\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,OR(DimVehicle[Color] = \"Black\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,DimVehicle[Color] = \"Blue\"))\n,\"Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>The shortened output from this piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"207\" height=\"257\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-8.png\" alt=\"\" class=\"wp-image-93038\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>If you want to apply multiple alternatives, you <em>can<\/em> nest <code>OR()<\/code> clauses (although this can get a little clunky). A cleaner option is to use the || operator in this way:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\n&nbsp;DimVehicle[Make]\n,DimVehicle[Model]\n,DimVehicle[Color]\n,FILTER(\n        VALUES(DimVehicle[Color])\n        ,DimVehicle[Color] = \"Black\"\n         || DimVehicle[Color] = \"Blue\" \n         || DimVehicle[Color] = \"Green\")\n,\"Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>The shortened output from this piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"319\" height=\"254\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-9.png\" alt=\"\" class=\"wp-image-93039\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>A more elegant solution to multiple alternatives (still for the same field) is to use the DAX row constructor (<code>IN<\/code>) using <code>IN {\u201c\u201d, \u201c\u201d, \u201c\u201d}<\/code> rather than the <code>OR<\/code> operator, as you can see from the following code snippet.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\t\n&nbsp;DimVehicle[Make]\n,DimVehicle[Model]\n,DimGeography[CountryName]\n,FILTER(\n        VALUES(DimGeography[CountryName])\n        ,DimGeography[CountryName] IN {\"France\", \"United States\",\n                                       \"Belgium\"})\n,\"Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>The shortened output from this piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"348\" height=\"252\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-10.png\" alt=\"\" class=\"wp-image-93040\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>All you have to do here is add the comma-separated list of elements to filter on inside curly braces after the <code>IN <\/code>keyword.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-date-filters\">Date Filters<\/h3>\n\n\n\n<p>Dates can be used simply and easily in filters. The main points to remember are that:<\/p>\n\n\n<div class=\"block-core-list\">\n<ul class=\"wp-block-list\">\n<li>Dates must be entered in a recognised date format.<\/li>\n\n\n\n<li>As dates are entered as text, they have to be wrapped in the <code>VALUE()<\/code> function to convert them into a date datatype that can be understood by DAX.<\/li>\n<\/ul>\n<\/div>\n\n\n<p>The following code snippet shows a simple date filter:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS(\n&nbsp;DimCLient[ClientName]\n,DimVehicle[Make]\n,DimVehicle[Model]\n,DimDate[DateKey]\n,FILTER(\n        VALUES(DimDate[DateKey])\n        ,DimDate[DateKey] &gt;= VALUE(\"01\/01\/2020\"))\n,\"Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>The shortened output from this piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"380\" height=\"249\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-11.png\" alt=\"\" class=\"wp-image-93041\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Date ranges merely extend the approach that you just saw, using the <code>AND<\/code> function:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS(\n&nbsp;DimCLient[ClientName]\n,DimVehicle[Make]\n,DimVehicle[Model]\n,DimDate[DateKey]\n,FILTER(\n        VALUES(DimDate[DateKey])\n        ,AND(DimDate[DateKey] &gt;= VALUE(\"01\/01\/2020\")\n        ,DimDate[DateKey]&lt;= VALUE(\"12\/30\/2022\"))\n       )\n,\"Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>In this case the output is like this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"699\" height=\"358\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/table-description-automatically-generated.png\" alt=\"Table\n\nDescription automatically generated\" class=\"wp-image-93042\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Or, if you prefer, the AND operator (<code>&amp;&amp;<\/code>) (which gives the same result so I will not repeat the display of the output):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS(\n&nbsp;DimCLient[ClientName]\n,DimVehicle[Make]\n,DimVehicle[Model]\n,DimDate[DateKey]\n,FILTER(\n        VALUES(DimDate[DateKey])\n        ,DimDate[DateKey] &gt;= VALUE(\"01\/01\/2020\")\n         &amp;&amp; \n         DimDate[DateKey]&lt;= VALUE(\"12\/30\/2022\")\n       )\n,\"Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-sql-like-in-dax\">SQL \u201cLIKE\u201d in DAX<\/h3>\n\n\n\n<p>If you are an SSRS developer looking for the SQL <code>LIKE<\/code> operator in DAX queries, then it is worth noting that DAX has two functions that you will undoubtedly find useful. They are:<\/p>\n\n\n\n<p>CONTAINSSTRING<\/p>\n\n\n\n<p>CONTAINSSTRINGEXACT<\/p>\n\n\n\n<p>The former can be applied to filter data where a string is found inside a field (regardless of the capitalisation). The latter is a case-sensitive text filter.<\/p>\n\n\n\n<p>You can filter data to return records containing a given string using code like that shown below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\n&nbsp;DimVehicle[Make]\n,DimVehicle[Model]\n,DimCLient[ClientName]\n,FILTER(DimCLient, CONTAINSSTRING(DimCLient[ClientName], \"Bling\"))\n,\"Total Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>The output from this short piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"262\" height=\"104\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-12.png\" alt=\"\" class=\"wp-image-93043\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>It is worth noting that you simply replace <code>CONTAINSSTRING<\/code> with <code>CONTAINSSTRINGEXACT<\/code> to apply case-sensitivity in the filter.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-null-handling\">NULL handling<\/h3>\n\n\n\n<p>Power BI datasets, like most data sources, can contain <code>NULL<\/code> (or empty) elements. You need to be able to filter out records where certain fields contain <code>NULLS<\/code>. This is done using the DAX <code>ISBLANK()<\/code> function, like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\n&nbsp;DimVehicle[Make]\n,DimVehicle[Model]\n, DimVehicle[ModelVariant]\n,FILTER(DimVehicle, ISBLANK(DimVehicle[ModelVariant]))\n,\"Total Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>The shortened output from this short piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"376\" height=\"252\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-13.png\" alt=\"\" class=\"wp-image-93044\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-boolean-filters\">Boolean Filters<\/h3>\n\n\n\n<p>If your Power BI dataset contains Boolean fields, you can apply a Boolean filter to exclude records like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\nDimCLient[ClientName]\n,DimCLient[IsReseller]\n,FILTER(VALUES(DimCLient[IsReseller]), NOT DimCLient[IsReseller])\n,\"Total Sales\", SUM(FactSales[SalePrice])\n)<\/pre>\n\n\n\n<p>The shortened output from this short piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"242\" height=\"251\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-14.png\" alt=\"\" class=\"wp-image-93045\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>To display clients where the <code>IsReseller<\/code> field is True, you would use DAX like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">FILTER(VALUES(DimCLient[IsReseller]), DimCLient[IsReseller])<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-sorting-data\">Sorting Data<\/h2>\n\n\n\n<p>To conclude the whirlwind tour of basic data retrieval (developed further in the next article), you need to know how to sort the output data. This is as simple as adding <code>ORDER BY<\/code> at the end of the DAX, like this.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">EVALUATE\nSUMMARIZECOLUMNS\n(\n&nbsp;DimVehicle[Make]\n,DimVehicle[Model]\n,DimGeography[CountryName]\n,FILTER(\n        VALUES(DimGeography[CountryName])\n        ,DimGeography[CountryName] IN {\"France\", \"United States\",\n                                       \"Belgium\"})\n,\"Total Sales\", SUM(FactSales[SalePrice])\n)\nORDER BY DimVehicle[Make]<\/pre>\n\n\n\n<p>The partial output from this short piece of DAX is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"285\" height=\"258\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/12\/word-image-15.png\" alt=\"\" class=\"wp-image-93046\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>It is worth noting that:<\/p>\n\n\n\n<p>You can define the sort order using the <code>ASC<\/code> and <code>DESC<\/code> keywords. So, to sort the previous output in descending order, the ORDER BY clause would read: ORDER BY DimVehicle[Make] DESC<\/p>\n\n\n\n<p>You cannot sort on a column that is not returned by the SUMMARIZECOLUMNS()function. In other words, you <strong>have<\/strong> to include the column to sort on in the output. However, in SSRS reports, the column used for sorting lists is virtually always displayed, in my experience. In any case, you do not have to display a column that you return to an SSRS dataset, so this is not usually a problem. It merely increases the size of the dataset returned to the report.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>In this article, you have seen many of the core techniques that you can apply when filtering source datasets that feed into paginated reports. This ranged from simple <code>AND<\/code> filters through <code>OR<\/code> filters to <code>NULL<\/code> handling \u2013 and, of course, sorting data. The third article in this series will look in-depth at using the various DAX table functions to help you create paginated reports from a Power BI dataset.<\/p>\n\n\n\n<section id=\"faq\" class=\"faq-block my-5xl\">\n    <h2>FAQs: How to Filter DAX for Paginated Reports<\/h2>\n\n                        <h3 class=\"mt-4xl\">1. How do you filter data in DAX for paginated reports?<\/h3>\n            <div class=\"faq-answer\">\n                <p>Use the SUMMARIZECOLUMNS function with filter arguments placed after the column list. Basic filters go as additional arguments to SUMMARIZECOLUMNS using TREATAS or direct filter syntax. For more complex filtering like OR logic, you&#8217;ll need to use CALCULATETABLE or nested FILTER functions rather than multiple SUMMARIZECOLUMNS filter arguments.<\/p>\n            <\/div>\n                    <h3 class=\"mt-4xl\">2. What is rscustomdaxfilter in paginated reports?<\/h3>\n            <div class=\"faq-answer\">\n                <p>rscustomdaxfilter is a technique for passing user-selected parameter values from Power BI Report Builder into a DAX query. It allows you to create dynamic, interactive paginated reports where end users can filter data at runtime &#8211; similar to how parameters work in traditional SSRS reports with SQL data sources.<\/p>\n            <\/div>\n                    <h3 class=\"mt-4xl\">3. Can you use WHERE in DAX like SQL?<\/h3>\n            <div class=\"faq-answer\">\n                <p>No. DAX doesn&#8217;t have a WHERE clause. Instead, you filter data using functions like FILTER, CALCULATETABLE, or filter arguments within SUMMARIZECOLUMNS. The conceptual shift from SQL is that DAX filtering modifies the filter context of an expression rather than filtering rows from a result set.<\/p>\n            <\/div>\n            <\/section>\n","protected":false},"excerpt":{"rendered":"<p>Master DAX filtering for paginated reports using SUMMARIZECOLUMNS. Covers basic filters, OR logic, expressions, and rscustomdaxfilter for Power BI Premium SSRS.&hellip;<\/p>\n","protected":false},"author":2181,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143528,53],"tags":[5134],"coauthors":[12351],"class_list":["post-93031","post","type-post","status-publish","format-standard","hentry","category-bi-sql-server","category-featured","tag-sql-prompt"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/93031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/2181"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=93031"}],"version-history":[{"count":7,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/93031\/revisions"}],"predecessor-version":[{"id":109009,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/93031\/revisions\/109009"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=93031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=93031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=93031"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=93031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}