<?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: How to Report on an End date that falls within 2 Date Columns from another Table?? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Report-on-an-End-date-that-falls-within-2-Date-Columns/m-p/2464171#M66881</link>
    <description>&lt;P&gt;Additional Question with this one - Now that I have the policy count, I want to try to get a distinct count on the propect ID associated with the policies.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, in the same table there is a prospectid assigned to each policy.&amp;nbsp; There can be multiple policy records with the same ProspectID so I want to filter the result down to just the distinct ProspectId's.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the dax measure I created but currently it is giving me the full count of policies, not grouped by prospects:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;Customers Insured - Personal Lines (Total) = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;COUNTx&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines[AmsPolicyEffectiveDate]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;=&lt;/SPAN&gt;&lt;SPAN&gt;max&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;) &amp;amp;&amp;amp; (&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines[AMSPolicyStatus Return Date Element 2]&lt;/SPAN&gt;&lt;SPAN&gt;) || &lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines[AMSPolicyStatus Return Date Element 2]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;max&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))),(&lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines[ProspectID]&lt;/SPAN&gt;&lt;SPAN&gt;)),&lt;/SPAN&gt;&lt;SPAN&gt;CROSSFILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines[AmsPolicyEffectiveDate]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'Date'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;None&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 19 Apr 2022 17:48:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-04-19T17:48:21Z</dc:date>
    <item>
      <title>How to Report on an End date that falls within 2 Date Columns from another Table??</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Report-on-an-End-date-that-falls-within-2-Date-Columns/m-p/2462197#M66707</link>
      <description>&lt;P&gt;I am trying to solve a bit of a conundrum I have come up against.&amp;nbsp; I appreciate any time/support/tips you all may have in order to solve this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Issue:&lt;/STRONG&gt; I am trying to find the count of policies that are active and in force during a user selected date, allowing me to report on any date and see the policies that are effective during that date.&amp;nbsp; In sql, I can achieve this by using the below query:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;"Declare @BeginningPeriod as date = '2022-01-01'&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Declare @EndPeriod as date = '2022-03-31'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;select count(AmsPolicyId) as TotalPL&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;from ProspectPolicy as PP&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;left join dw.OriginalPolicyTransactionTypes as OPTT on OPTT.Id = PP.Id&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;where&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;@EndPeriod between PP.AmsPolicyEffectiveDate and&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;case when PP.AMSPolicyStatus = 'C' then&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;case when PP.AmsPolicyEffectiveDate = OPTT.NewestTransactionEffectiveDate then PP.AmsPolicyExpirationDate&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;else OPTT.NewestTransactionEffectiveDate end&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;else PP.AmsPolicyExpirationDate end&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;and PP.AmsPolicySubType = 'Policy' and (PP.TypeOfBusiness = '0' or PP.TypeOfBusiness = '1')&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;and PP.DeletedBy is nullE&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;EM&gt;and PP.AmsPolicyId is not null"&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;STRONG&gt;So essentially, I am trying to allow my users to declare an "&lt;EM&gt;endperiod&lt;/EM&gt;" date and get power bi to evaluate if that end period falls between the date parameters dictated in my query and return the total number of policies in force at that time.&amp;nbsp;&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Steps I have taken so Far:&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;1) I imported the table "Prospect Policy" which contains my AMSPolicyEffectivedate and the AMSPolicyExpirationDate.&amp;nbsp; I also imported the table "dw.OriginalPolicyTransactionTypes" which contains my column: "&lt;EM&gt;OPTT.NewestTransactionEffectiveDate&lt;/EM&gt;".&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;2) I related the table on ProspectPolicyID and OriginalPolicyTransactionTypesID in my data model/schema (as they are corresponding fields in the db).&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;3) I created a column in my Prospect Policy Table to bring in the OPTT.NewestTransactionEffectiveDate into my Prospect Policy Table:&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;OPTT.Newesttransactioneffectivedate = Lookupvalue('dw OriginalPolicyTransactionTypes'[NewestTransactionEffectiveDate],'dw OriginalPolicyTransactionTypes'[Id],ProspectPolicy[Id])&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;4) I then created another column to find the correct date that should be returned based on the criteria in my SQL query:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;AMSPolicyStatus Return Date Element 2 = IF(ProspectPolicy[AmsPolicyStatus]= "C" &amp;amp;&amp;amp; ProspectPolicy[AmsPolicyEffectiveDate] &amp;lt;&amp;gt; ProspectPolicy[OPTT.Newesttransactioneffectivedate],ProspectPolicy[OPTT.Newesttransactioneffectivedate],ProspectPolicy[AmsPolicyExpirationDate])&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I then created a measure that filters the rest of the criteria for what i am looking for to return the total policies in force:&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;Policies in Force - Personal Lines (Total) = &lt;/SPAN&gt;&lt;SPAN&gt;Calculate&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Count&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ProspectPolicy[AmsPolicyId]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;ProspectPolicy[AmsPolicySubType]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"Policy"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;ProspectPolicy[TypeOfBusiness]&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt; || &lt;/SPAN&gt;&lt;SPAN&gt;ProspectPolicy[TypeOfBusiness]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;ProspectPolicy[DeletedBy]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;BLANK&lt;/SPAN&gt;&lt;SPAN&gt;(),&lt;/SPAN&gt;&lt;SPAN&gt;ProspectPolicy[AmsPolicyId]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;BLANK&lt;/SPAN&gt;&lt;SPAN&gt;())&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;My remaining issue is this:&lt;/STRONG&gt;&lt;/FONT&gt; How do create a filter for the "Endperiod" date that will only return the count of my values in my measure that have the user selected "&lt;EM&gt;endperiod&lt;/EM&gt;" date between the "&lt;EM&gt;Amspolicyeffectivedate&lt;/EM&gt;" and the date from the calculated column I created: "&lt;EM&gt;AMSPolicyStatus Return Date Element 2"?&amp;nbsp;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 20:50:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Report-on-an-End-date-that-falls-within-2-Date-Columns/m-p/2462197#M66707</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-18T20:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to Report on an End date that falls within 2 Date Columns from another Table??</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Report-on-an-End-date-that-falls-within-2-Date-Columns/m-p/2462500#M66732</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , Using an independent date table for date selection &lt;/P&gt;
&lt;P&gt;measure = &lt;BR /&gt;var _max = maxx(allselected(Date1),Date1[Date])&lt;BR /&gt;return &lt;BR /&gt;calculate(&lt;BR /&gt;Count(ProspectPolicy[ProspectPolicyID]), Filter(ProspectPolicy, ProspectPolicy[OPTT.Newesttransactioneffectivedate] &amp;lt;=_max &amp;amp;&amp;amp; &lt;BR /&gt;ProspectPolicy[AmsPolicyExpirationDate] &amp;gt;= _max))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;also check - Active employee code here&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 04:05:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Report-on-an-End-date-that-falls-within-2-Date-Columns/m-p/2462500#M66732</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-04-19T04:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to Report on an End date that falls within 2 Date Columns from another Table??</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Report-on-an-End-date-that-falls-within-2-Date-Columns/m-p/2463796#M66840</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;- Using your Active Employee code tutorial was incredibly helpful and assisted me in getting it done.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Great work and thank you for the assitance!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 14:33:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Report-on-an-End-date-that-falls-within-2-Date-Columns/m-p/2463796#M66840</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-19T14:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to Report on an End date that falls within 2 Date Columns from another Table??</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Report-on-an-End-date-that-falls-within-2-Date-Columns/m-p/2464171#M66881</link>
      <description>&lt;P&gt;Additional Question with this one - Now that I have the policy count, I want to try to get a distinct count on the propect ID associated with the policies.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, in the same table there is a prospectid assigned to each policy.&amp;nbsp; There can be multiple policy records with the same ProspectID so I want to filter the result down to just the distinct ProspectId's.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the dax measure I created but currently it is giving me the full count of policies, not grouped by prospects:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN&gt;Customers Insured - Personal Lines (Total) = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;COUNTx&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines[AmsPolicyEffectiveDate]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;=&lt;/SPAN&gt;&lt;SPAN&gt;max&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;) &amp;amp;&amp;amp; (&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines[AMSPolicyStatus Return Date Element 2]&lt;/SPAN&gt;&lt;SPAN&gt;) || &lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines[AMSPolicyStatus Return Date Element 2]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;max&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))),(&lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines[ProspectID]&lt;/SPAN&gt;&lt;SPAN&gt;)),&lt;/SPAN&gt;&lt;SPAN&gt;CROSSFILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;PP_PersonalLines[AmsPolicyEffectiveDate]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'Date'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;None&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 19 Apr 2022 17:48:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-Report-on-an-End-date-that-falls-within-2-Date-Columns/m-p/2464171#M66881</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-19T17:48:21Z</dc:date>
    </item>
  </channel>
</rss>

