<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using a filter as a value in an expression. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/83263#M121</link>
    <description>&lt;P&gt;Not sure if you have solved this yet but I came across this post and it may help:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://community.powerbi.com/t5/Desktop/Linking-2-or-more-dates-to-one-Master-Calendar-USERELATIONSHIP/m-p/9316" target="_blank"&gt;http://community.powerbi.com/t5/Desktop/Linking-2-or-more-dates-to-one-Master-Calendar-USERELATIONSHIP/m-p/9316&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I am not sure what you mean by "no relationship between the Calendar[Date] table" and the dates in your store data table. &amp;nbsp;Did you create a relationship?&lt;/P&gt;</description>
    <pubDate>Thu, 27 Oct 2016 18:12:16 GMT</pubDate>
    <dc:creator>dkay84_PowerBI</dc:creator>
    <dc:date>2016-10-27T18:12:16Z</dc:date>
    <item>
      <title>Using a filter as a value in an expression.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/79664#M107</link>
      <description>&lt;P&gt;Here’s a problem I hope there’s an answer for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data table has a list of stores and in that table it includes two date fields (Store Close date and a date when the store becomes a comparative store)&lt;/P&gt;&lt;P&gt;I have a separate date table that I want to use as a filter. They two tables are not currently related/linked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The business requirement is that the users want to be able to set a date in the filter&amp;nbsp;and see all comp stores as of that date filter. They basically want to pick a date and see what stores were comp stores AT THAT TIME.&amp;nbsp;&amp;nbsp; I thought I could do this by comapring the filter date value to the column values in the table.&amp;nbsp; Saddly, No.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The rules are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;compdate &amp;gt;= Filter date &amp;lt;= ClosedDate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Store was a comp store but wasn’t closed at the filter date time frame)&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;CompDate &amp;gt;= filter date AND ClosedDate is NULL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (store is a comp store and is still open))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I use the filter as a value in an expression?&lt;/P&gt;&lt;P&gt;Basically some sort of Calculate(CountA([xxx]), date[date]&amp;gt;= table[CompDate], date[date]&amp;lt;= table[ClosedDate])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 20:23:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/79664#M107</guid>
      <dc:creator>ReubenLam</dc:creator>
      <dc:date>2016-10-18T20:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using a filter as a value in an expression.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/79684#M108</link>
      <description>Take a look at the following. It sounds like it could be a solution for you (don't let the simplicity of the URL deter you):&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.daxpatterns.com/distinct-count/" target="_blank"&gt;http://www.daxpatterns.com/distinct-count/&lt;/A&gt;</description>
      <pubDate>Tue, 18 Oct 2016 21:07:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/79684#M108</guid>
      <dc:creator>dkay84_PowerBI</dc:creator>
      <dc:date>2016-10-18T21:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using a filter as a value in an expression.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/79699#M109</link>
      <description>&lt;P&gt;In this case, that solution doesn't work as there's no relation between the Calendar[Date] table and any of the dates in the store data table.&amp;nbsp; User picks an arbitrary date from the filter and I want to compare it to two separate dates fields in the store data.&amp;nbsp; basically using the filter as a value in a logic test.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 22:30:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/79699#M109</guid>
      <dc:creator>ReubenLam</dc:creator>
      <dc:date>2016-10-18T22:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using a filter as a value in an expression.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/83263#M121</link>
      <description>&lt;P&gt;Not sure if you have solved this yet but I came across this post and it may help:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://community.powerbi.com/t5/Desktop/Linking-2-or-more-dates-to-one-Master-Calendar-USERELATIONSHIP/m-p/9316" target="_blank"&gt;http://community.powerbi.com/t5/Desktop/Linking-2-or-more-dates-to-one-Master-Calendar-USERELATIONSHIP/m-p/9316&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I am not sure what you mean by "no relationship between the Calendar[Date] table" and the dates in your store data table. &amp;nbsp;Did you create a relationship?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2016 18:12:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/83263#M121</guid>
      <dc:creator>dkay84_PowerBI</dc:creator>
      <dc:date>2016-10-27T18:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using a filter as a value in an expression.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/3402982#M128534</link>
      <description>&lt;P&gt;The problem you're facing is quite common when trying to incorporate a disconnected date table to filter another table based on different date-related criteria. In DAX (the formula language for Power BI and other Microsoft BI tools), you can indeed retrieve a single value from a filter context and use that in a calculation. In your case, you want to get the selected date from the date table's filter context.&lt;/P&gt;
&lt;P&gt;To get the selected date from the filter context, we'll use the MAX function (or MIN, either one will work assuming only one date is selected at a time).&lt;/P&gt;
&lt;P&gt;Let's assume your date table is named DateTable and the date column in that table is DateValue.&lt;/P&gt;
&lt;P&gt;To get the selected date:&lt;/P&gt;
&lt;P&gt;SelectedDate = MAX(DateTable[DateValue])&lt;BR /&gt;Next, let's create a measure that counts the stores that were comp stores at the selected date:&lt;/P&gt;
&lt;P&gt;CountOfCompStores = &lt;BR /&gt;VAR CurrentDate = [SelectedDate]&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTA('Stores'[StoreName]),&lt;BR /&gt;FILTER(&lt;BR /&gt;'Stores',&lt;BR /&gt;('Stores'[compdate] &amp;lt;= CurrentDate &amp;amp;&amp;amp; CurrentDate &amp;lt;= 'Stores'[ClosedDate]) || &lt;BR /&gt;('Stores'[compdate] &amp;lt;= CurrentDate &amp;amp;&amp;amp; ISBLANK('Stores'[ClosedDate]))&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;This measure first captures the currently selected date into a variable called CurrentDate and then uses CALCULATE and FILTER to determine which rows of the 'Stores' table meet the comp store criteria based on CurrentDate.&lt;/P&gt;
&lt;P&gt;By using this measure in your report, users can select a date from DateTable, and the measure will show the count of stores that were comp stores at that specific date, as per your rules.&lt;/P&gt;
&lt;P&gt;Please note that this measure assumes that your store table's name is 'Stores' and has a column 'StoreName' to count. Adjust the table and column references accordingly.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 20:38:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-filter-as-a-value-in-an-expression/m-p/3402982#M128534</guid>
      <dc:creator>technolog</dc:creator>
      <dc:date>2023-08-28T20:38:13Z</dc:date>
    </item>
  </channel>
</rss>

