<?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 DateDiff with Selected Date Value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Selected-Date-Value/m-p/2863443#M92246</link>
    <description>&lt;P&gt;Hello, hope you all doing good. I'm trying to Calculate several measures (sales total, etc) but having a filter named "Tenure" which have two options, &amp;lt; 60 Days or &amp;gt;= 60 Days, this values needs to consider the DateDiff between the Agent's Production Date and the Date Selected from Calendar Table, i.e.&amp;nbsp;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Those are two tables, Roster and Sales, if I select from Calendar table 05/17/2022, and from Tenure filter &amp;gt;=60 Days it should show Agent A and Agent B with their sales (because the Tenure is based on the DateDiff bewteen the Selected Date (05/17/2022) and the Agent's Production Dates (9/10/2021 and 2/12/2022). If I select the same Date (05/17/2022) but now from Tenure &amp;lt;60 Days, it should show Agent C because the DateDiff is less than 60.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another thing is if I select multiple values from the Calendar Table, it should consider the last one (i.e. if I select from May 1st to May 5th, the datediff should be with May 5th).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already found the way to show the correct values from my calculate measures if I select wheter &amp;lt; 60 Days, &amp;gt;= 60 Days or both for one single selected Date, the problem is when I select multiple values and it shows me everything without considering the max date selected.&lt;/P&gt;</description>
    <pubDate>Wed, 26 Oct 2022 05:06:29 GMT</pubDate>
    <dc:creator>Gutierrez</dc:creator>
    <dc:date>2022-10-26T05:06:29Z</dc:date>
    <item>
      <title>DateDiff with Selected Date Value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Selected-Date-Value/m-p/2863443#M92246</link>
      <description>&lt;P&gt;Hello, hope you all doing good. I'm trying to Calculate several measures (sales total, etc) but having a filter named "Tenure" which have two options, &amp;lt; 60 Days or &amp;gt;= 60 Days, this values needs to consider the DateDiff between the Agent's Production Date and the Date Selected from Calendar Table, i.e.&amp;nbsp;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Those are two tables, Roster and Sales, if I select from Calendar table 05/17/2022, and from Tenure filter &amp;gt;=60 Days it should show Agent A and Agent B with their sales (because the Tenure is based on the DateDiff bewteen the Selected Date (05/17/2022) and the Agent's Production Dates (9/10/2021 and 2/12/2022). If I select the same Date (05/17/2022) but now from Tenure &amp;lt;60 Days, it should show Agent C because the DateDiff is less than 60.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another thing is if I select multiple values from the Calendar Table, it should consider the last one (i.e. if I select from May 1st to May 5th, the datediff should be with May 5th).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already found the way to show the correct values from my calculate measures if I select wheter &amp;lt; 60 Days, &amp;gt;= 60 Days or both for one single selected Date, the problem is when I select multiple values and it shows me everything without considering the max date selected.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 05:06:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Selected-Date-Value/m-p/2863443#M92246</guid>
      <dc:creator>Gutierrez</dc:creator>
      <dc:date>2022-10-26T05:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff with Selected Date Value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Selected-Date-Value/m-p/2867078#M92404</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="462015" data-lia-user-login="Gutierrez" class="lia-mention lia-mention-user"&gt;Gutierrez&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I created a sample pbix file(see&lt;EM&gt;&lt;STRONG&gt; the attachment&lt;/STRONG&gt;&lt;/EM&gt;), please check if that is what you want.&lt;/P&gt;
&lt;P&gt;1. Create a &lt;STRONG&gt;measure&lt;/STRONG&gt; as below to judge if the data is in the period&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Flag = 
VAR _maxdate =
    MAX ( 'Calendar'[Date] )
VAR _seltenure =
    SELECTEDVALUE ( 'Tenure'[Tenure] )
VAR _selagent =
    SELECTEDVALUE ( 'Sales'[AGENT NAME] )
VAR _pdate =
    CALCULATE (
        MAX ( 'Roster'[PRODUCTION DATE] ),
        FILTER ( 'Roster', 'Roster'[AGENT NAME] = _selagent )
    )
RETURN
    IF (
        _seltenure = "&amp;gt;= 60 Days"
            &amp;amp;&amp;amp; DATEDIFF ( _pdate, _maxdate, DAY ) &amp;gt;= 60,
        1,
        IF ( _seltenure = "&amp;lt; 60 Days" &amp;amp;&amp;amp; DATEDIFF ( _pdate, _maxdate, DAY ) &amp;lt; 60, 1, 0 )
    )&lt;/LI-CODE&gt;
&lt;P&gt;2. Create a table visual as below screenshot and apply a visal-level filter on it with the condition (&lt;EM&gt;&lt;STRONG&gt;Flag is 1&lt;/STRONG&gt;&lt;/EM&gt;)&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If the above one can't help you get the desired result, please provide more&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;in your tables (&lt;STRONG&gt;&lt;EM&gt;exclude&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&lt;STRONG&gt;sensitive&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;&lt;EM&gt;data&lt;/EM&gt;&lt;/STRONG&gt;) with&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;/STRONG&gt;&amp;nbsp;with backend logic and special examples.&amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;It is better&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;if you can share a&amp;nbsp;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;simplified&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;pbix file. You can refer the following link to upload the file to the community. Thank you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=04%7C01%7Cv-yiruan%40microsoft.com%7C4f580813734d4a8355b008da16f6e91a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637847547341062885%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;amp;sdata=YJvujige2YITXKbKED9JieQm5LBdf%2F3IYPM4ggdiijQ%3D&amp;amp;reserved=0" target="_blank" rel="nofollow noopener noreferrer"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2022 07:47:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Selected-Date-Value/m-p/2867078#M92404</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-27T07:47:31Z</dc:date>
    </item>
  </channel>
</rss>

