<?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: Checking if selected date slicer is between 2 date columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Checking-if-selected-date-slicer-is-between-2-date-columns/m-p/4340330#M172334</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="801139" data-lia-user-login="wjlee" class="lia-mention lia-mention-user"&gt;wjlee&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="796215" data-lia-user-login="dharmendars007" class="lia-mention lia-mention-user"&gt;dharmendars007&lt;/a&gt;'s reply. He&amp;nbsp;provides a way for you to try to see if it works, and if it doesn't fit your needs, can you explain why after selecting 2024/12/20 it has to be the yellow two line DateCheck output 1, which requires a logic.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P style="text-align: justify; text-justify: inter-ideograph;"&gt;&lt;SPAN&gt;Best Regards,&lt;BR /&gt;Yang&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Community Support Team&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Dec 2024 06:44:11 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-12-23T06:44:11Z</dc:date>
    <item>
      <title>Checking if selected date slicer is between 2 date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Checking-if-selected-date-slicer-is-between-2-date-columns/m-p/4337980#M172248</link>
      <description>&lt;P&gt;Hi all, I am facing difficulty figuring out how to check if a selected value of a date slicer is in between 2 date columns.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Use Case -&lt;/STRONG&gt;&lt;BR /&gt;When the user selects a date in the date slicer, there should be a measure to check that the selected date is between the StartDate column and EndDate column of the latest row created (indicated by RankByProjectDate = 1). It doesn't need to check if the RankByProjectDate =/= 1.&lt;BR /&gt;If it is between the StartDate and EndDate, return DistinctCount of the ProjectId (or just return 1).&lt;BR /&gt;If it is not between the StartDate and EndDate, return 0.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;The Problem -&lt;/STRONG&gt;&lt;BR /&gt;I have a fact table called "ValuesGen" that contains the following data -&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;There is a single select Date slicer based on my Date table -&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Expected Results -&lt;/STRONG&gt;&lt;BR /&gt;1) If the user selects the date as "20 December 2024", the DateCheck measure should return 1 (as indicated in the image below), as RankByProjectDate = 1, and the selected date is between the StartDate and EndDate.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;2) If the user selects the date as "5 September 2024", the DateCheck measure should return 1 (as indicated in the image below), as RankByProjectDate = 1, and the selected date is between the StartDate and EndDate.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The Model -&lt;/STRONG&gt;&lt;BR /&gt;My Date table is connected to the "ValuesGen" table via a one-to-many relationship as illustrated below -&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;What I've Tried -&lt;/STRONG&gt;&lt;BR /&gt;I've tried implementing the following measures but clearly DateCheck isn't working, and I'm not sure how to proceed. Could I get some advice on fixing this or is there an easier/better way to do it?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RankByProjectDate = 
RANKX(
    FILTER(
        ValuesGen, // Ignores filters from the slicer on this table
        ValuesGen[ProjectID] = EARLIER(ValuesGen[ProjectID])
    ),
    ValuesGen[CreatedDatetime],
    ,
    DESC
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;_DateCheck = 
VAR SelectedDate = SELECTEDVALUE('_DateTable'[Date])

VAR _StartDate = CALCULATE(MAX(ValuesGen[StartDate]), FILTER (ValuesGen, ValuesGen[RankByProjectDate] = "1"))

VAR _EndDate = CALCULATE(MAX(ValuesGen[EndDate]), FILTER (ValuesGen, ValuesGen[RankByProjectDate] = "1"))

VAR _Value = CALCULATE(DISTINCTCOUNT(ValuesGen[ProjectId]), FILTER (ValuesGen, ValuesGen[RankByProjectDate] = "1"))

RETURN
IF(SelectedDate &amp;gt;= _StartDate &amp;amp;&amp;amp; SelectedDate &amp;lt;= _EndDate, 1 , 0)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Any help is very much appreciated.&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 04:35:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Checking-if-selected-date-slicer-is-between-2-date-columns/m-p/4337980#M172248</guid>
      <dc:creator>wjlee</dc:creator>
      <dc:date>2024-12-20T04:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Checking if selected date slicer is between 2 date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Checking-if-selected-date-slicer-is-between-2-date-columns/m-p/4338175#M172256</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="801139" data-lia-user-login="wjlee" class="lia-mention lia-mention-user"&gt;wjlee&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try the below corrected bersion of DAX..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;DateCheck = &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;VAR SelectedDate = SELECTEDVALUE('Date'[Date]) -- Get the selected date from the slicer&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;RETURN&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;IF (ISBLANK(SelectedDate), &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;0, -- No date is selected, return 0&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;IF (SUMX(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;FILTER(MainCalendar,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;SelectedDate &amp;gt;= MainCalendar[StartDate] &amp;amp;&amp;amp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;SelectedDate &amp;lt;= MainCalendar[EndDate]),1) &amp;gt; 0,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;1, -- Date falls within the range&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;0 -- Date does not fall within the range))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Outer IF Conditions&amp;gt;&amp;gt; Returns 1 if at least one match is found, Returns 0 otherwise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; are much appreciated!&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;P&gt;Dharmendar S&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.linkedin.com/in/dharmendar-s-b5b43463/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;LinkedIN&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 07:13:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Checking-if-selected-date-slicer-is-between-2-date-columns/m-p/4338175#M172256</guid>
      <dc:creator>dharmendars007</dc:creator>
      <dc:date>2024-12-20T07:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Checking if selected date slicer is between 2 date columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Checking-if-selected-date-slicer-is-between-2-date-columns/m-p/4340330#M172334</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="801139" data-lia-user-login="wjlee" class="lia-mention lia-mention-user"&gt;wjlee&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="796215" data-lia-user-login="dharmendars007" class="lia-mention lia-mention-user"&gt;dharmendars007&lt;/a&gt;'s reply. He&amp;nbsp;provides a way for you to try to see if it works, and if it doesn't fit your needs, can you explain why after selecting 2024/12/20 it has to be the yellow two line DateCheck output 1, which requires a logic.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P style="text-align: justify; text-justify: inter-ideograph;"&gt;&lt;SPAN&gt;Best Regards,&lt;BR /&gt;Yang&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Community Support Team&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2024 06:44:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Checking-if-selected-date-slicer-is-between-2-date-columns/m-p/4340330#M172334</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-23T06:44:11Z</dc:date>
    </item>
  </channel>
</rss>

