<?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: Days Between Dates DAX in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2862258#M92199</link>
    <description>&lt;P&gt;hello i know most of the solution but i dont know how to ignore blanks&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure sql to opp = 
VAR _mql = LASTDATE('DIMENSION LEAD TO OPP'[start_mql_date])
VAR _opp = FIRSTDATE('DIMENSION LEAD TO OPP'[start_opportunity_date])

RETURN
COUNTROWS(CALENDAR(_mql,_opp))-1&lt;/LI-CODE&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;but for when opp is blank or any date is blank it gives error&lt;/P&gt;</description>
    <pubDate>Tue, 25 Oct 2022 16:06:34 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-10-25T16:06:34Z</dc:date>
    <item>
      <title>Days Between Dates DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2861492#M92161</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to get days between certain dates to then show as an average in a matrix table / table. I would like to use a DAX measure and not add any further columns to my model.&lt;/P&gt;&lt;P&gt;I have two tables that have a relationship, Dimension Lead to Opp and FACT Lead to Opp, relationship view is available on attached PBI file.&lt;/P&gt;&lt;P&gt;I would like to see days between the 3 dates below:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Start Opportunity Date – Start MQL Date&lt;/LI&gt;&lt;LI&gt;Close Date – Start MQL Date&lt;/LI&gt;&lt;LI&gt;Close Date – Start Opportunity Date&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to show 0 or blank if the Start MQL date is blank to be able to exclude them from the average calculation. As it has not entered the criteria for the calculation. &amp;nbsp;Also blanks if any of the three fields are blank I would like to show blank as the result so it does not impact averages when I am giving a total number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AivZWzcfJJzngSP8be8JmJ8xq91l?e=MYiZ33" target="_blank" rel="noopener"&gt;https://1drv.ms/u/s!AivZWzcfJJzngSP8be8JmJ8xq91l?e=MYiZ33&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected Results attached.&amp;nbsp;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 15:33:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2861492#M92161</guid>
      <dc:creator>antlufc</dc:creator>
      <dc:date>2022-10-25T15:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Days Between Dates DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2862141#M92191</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="218027" data-lia-user-login="antlufc" class="lia-mention lia-mention-user"&gt;antlufc&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am unable to access your file. Can you copy paste your sample data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 15:09:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2862141#M92191</guid>
      <dc:creator>AnkitKukreja</dc:creator>
      <dc:date>2022-10-25T15:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Days Between Dates DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2862192#M92196</link>
      <description>&lt;P&gt;I have amended the link can you let me know if you can now access?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 15:34:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2862192#M92196</guid>
      <dc:creator>antlufc</dc:creator>
      <dc:date>2022-10-25T15:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Days Between Dates DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2862258#M92199</link>
      <description>&lt;P&gt;hello i know most of the solution but i dont know how to ignore blanks&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure sql to opp = 
VAR _mql = LASTDATE('DIMENSION LEAD TO OPP'[start_mql_date])
VAR _opp = FIRSTDATE('DIMENSION LEAD TO OPP'[start_opportunity_date])

RETURN
COUNTROWS(CALENDAR(_mql,_opp))-1&lt;/LI-CODE&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;but for when opp is blank or any date is blank it gives error&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 16:06:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2862258#M92199</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-25T16:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Days Between Dates DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2863884#M92267</link>
      <description>&lt;P&gt;Thanks for the suggestion, it has not worked due to "Calendar function can not be Blank value"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 07:57:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2863884#M92267</guid>
      <dc:creator>antlufc</dc:creator>
      <dc:date>2022-10-26T07:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Days Between Dates DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2864244#M92279</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="218027" data-lia-user-login="antlufc" class="lia-mention lia-mention-user"&gt;antlufc&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Firstly, please make sure [start_mql_date] and [start_opportunity_date] in "DIMENSION LEAD TO OPP" and [close_date] in "FACT LEAD TO OPP" are date type.&lt;/P&gt;
&lt;P&gt;Then you can create measures as below to achieve your goal.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Latest MQL Date = 
VAR _DATE = MAX('DIMENSION LEAD TO OPP'[start_mql_date])
RETURN
IF(_DATE = BLANK(),"Blank",_DATE)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;First Opp Date = 
VAR _DATE = MAX('DIMENSION LEAD TO OPP'[start_opportunity_date])
RETURN
IF(_DATE = BLANK(),"Blank",_DATE)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Close Date = 
VAR _DATE =
CALCULATE(MAX('FACT LEAD TO OPP'[close_date]),FILTER(ALL('FACT LEAD TO OPP'),'FACT LEAD TO OPP'[lead_to_opportunity_id] = MAX('DIMENSION LEAD TO OPP'[id])))
RETURN
IF(_DATE = BLANK(),"Blank",_DATE)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;MQL to Opp Days = 
VAR _DIFF = DATEDIFF(MAX('DIMENSION LEAD TO OPP'[start_mql_date]),MAX('DIMENSION LEAD TO OPP'[start_opportunity_date]),DAY)
RETURN
IF(_DIFF = BLANK(),"Blank",_DIFF)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;MQL to Close = 
VAR _MQL = MAX('DIMENSION LEAD TO OPP'[start_mql_date])
VAR _CLOSE = CALCULATE(MAX('FACT LEAD TO OPP'[close_date]),FILTER(ALL('FACT LEAD TO OPP'),'FACT LEAD TO OPP'[lead_to_opportunity_id] = MAX('DIMENSION LEAD TO OPP'[id])))
VAR _DIFF = DATEDIFF(_MQL,_CLOSE,DAY)
RETURN
IF(_DIFF = BLANK(),"Blank",_DIFF)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Opp Created to Close = 
VAR _Opp = MAX('DIMENSION LEAD TO OPP'[start_opportunity_date])
VAR _CLOSE = CALCULATE(MAX('FACT LEAD TO OPP'[close_date]),FILTER(ALL('FACT LEAD TO OPP'),'FACT LEAD TO OPP'[lead_to_opportunity_id] = MAX('DIMENSION LEAD TO OPP'[id])))
VAR _DIFF = DATEDIFF(_Opp,_CLOSE,DAY)
RETURN
IF(_DIFF = BLANK(),"Blank",_DIFF)&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 09:33:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2864244#M92279</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-26T09:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Days Between Dates DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2864392#M92282</link>
      <description>&lt;P&gt;I have an issue where the start mql date and start opp date are the same date ths is returning blanks however in this instance i would like it to return 0.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This would also be the case when start opp date and close opp date would be the same.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 10:03:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Days-Between-Dates-DAX/m-p/2864392#M92282</guid>
      <dc:creator>antlufc</dc:creator>
      <dc:date>2022-10-26T10:03:35Z</dc:date>
    </item>
  </channel>
</rss>

