<?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: Measure based on 2 date column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1320010#M23207</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Try this measure:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure = 
VAR D = FORMAT(MAX('Date'[Date]),"YYYYMM")
VAR _CANCELLED = 
    SUMX(
        FILTER(
            ALL(Sold),
                FORMAT(Sold[Cancelation date],"YYYYMM") = D
        ),
        [_SUM]   
    )
RETURN
 IF( HASONEVALUE('Date'[Date].[Mois]), 
   [_SUM] - _CANCELLED, 
   SUMX(
       ALL(Sold),
       IF( Sold[Status] = "Sold", Sold[Price] , Sold[Price] * -1)
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;________________________&lt;/P&gt;&lt;P&gt;Did I answer your question? Mark this post as a solution, this will help others!.&lt;/P&gt;&lt;P&gt;Click on the Thumbs-Up icon if you like this reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&lt;A href="https://www.youtube.com/channel/UCKwBEguA8IlBubIobaOormg?sub_confirmation=1" target="_blank"&gt;YouTube, &lt;/A&gt;&lt;A href="https://linkedin.com/in/fowmy" target="_blank"&gt;LinkedIn&lt;/A&gt;&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Aug 2020 16:20:17 GMT</pubDate>
    <dc:creator>Fowmy</dc:creator>
    <dc:date>2020-08-24T16:20:17Z</dc:date>
    <item>
      <title>Measure based on 2 date column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1319651#M23190</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a measure with 2 date column but with a little twist..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Sold Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp; Status&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Cancelation Date&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Price&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; Sold&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;$10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; Canceled&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Feb&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;$10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Feb&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; Sold&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;$10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ''Sold Date'' is linked to a date fact table. If you select January the total amount should be $20 (based on Sold Date) and if you select February, because there is a cancelation date, the amount need to be substracted from this month. Total for February should be $0. Any idea how to create a measure like that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 14:49:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1319651#M23190</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-24T14:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Measure based on 2 date column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1319688#M23191</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Can you share some sample data and the expected result to have a clear understanding of your question?&lt;BR /&gt;You can save your files in OneDrive, Google Drive, or any other cloud sharing platforms and share the link here.&lt;BR /&gt;____________________________________&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;How to paste sample data with your question?&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;How to get your questions answered quickly?&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;_____________________________________&lt;BR /&gt;Did I answer your question? Mark this post as a solution, this will help others!.&lt;/P&gt;&lt;P&gt;Click on the Thumbs-Up icon if you like this reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&lt;A href="https://www.youtube.com/channel/UCKwBEguA8IlBubIobaOormg?sub_confirmation=1" target="_blank"&gt;YouTube, &lt;/A&gt;&lt;A href="https://linkedin.com/in/fowmy" target="_blank"&gt;LinkedIn&lt;/A&gt;&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 14:24:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1319688#M23191</guid>
      <dc:creator>Fowmy</dc:creator>
      <dc:date>2020-08-24T14:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Measure based on 2 date column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1319806#M23199</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="52518" data-lia-user-login="Fowmy" class="lia-mention lia-mention-user"&gt;Fowmy&lt;/a&gt;&amp;nbsp; Here's the link:&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1thQdeZO9yuEnW5U4EOzGdlym9RIK57r0/view?usp=sharing" target="_blank" rel="noopener"&gt;https://drive.google.com/file/d/1thQdeZO9yuEnW5U4EOzGdlym9RIK57r0/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on the Date table, if you select January the total should be $20 (based on Sold Date column). If you choose february the total should be $0 ($10 sold in Feb - $10 from the cancelation of February). If you don't select any month, the total should be $10.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 15:10:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1319806#M23199</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-24T15:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Measure based on 2 date column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1320010#M23207</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Try this measure:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure = 
VAR D = FORMAT(MAX('Date'[Date]),"YYYYMM")
VAR _CANCELLED = 
    SUMX(
        FILTER(
            ALL(Sold),
                FORMAT(Sold[Cancelation date],"YYYYMM") = D
        ),
        [_SUM]   
    )
RETURN
 IF( HASONEVALUE('Date'[Date].[Mois]), 
   [_SUM] - _CANCELLED, 
   SUMX(
       ALL(Sold),
       IF( Sold[Status] = "Sold", Sold[Price] , Sold[Price] * -1)
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;________________________&lt;/P&gt;&lt;P&gt;Did I answer your question? Mark this post as a solution, this will help others!.&lt;/P&gt;&lt;P&gt;Click on the Thumbs-Up icon if you like this reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&lt;A href="https://www.youtube.com/channel/UCKwBEguA8IlBubIobaOormg?sub_confirmation=1" target="_blank"&gt;YouTube, &lt;/A&gt;&lt;A href="https://linkedin.com/in/fowmy" target="_blank"&gt;LinkedIn&lt;/A&gt;&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 16:20:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1320010#M23207</guid>
      <dc:creator>Fowmy</dc:creator>
      <dc:date>2020-08-24T16:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Measure based on 2 date column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1320325#M23212</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="52518" data-lia-user-login="Fowmy" class="lia-mention lia-mention-user"&gt;Fowmy&lt;/a&gt;&amp;nbsp; for your time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure how the [_SUM] should work... it's looking for a column called _SUM but there's none....&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 18:07:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1320325#M23212</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-24T18:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Measure based on 2 date column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1320379#M23214</link>
      <description>&lt;P&gt;Please try this measure in a table visual with your Sold Date column.&amp;nbsp; Replace Sold with your actual table name throughout.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Total Sold =&lt;BR /&gt;VAR thismonth =&lt;BR /&gt;SELECTEDVALUE ( Sold[Sold Date] )&lt;BR /&gt;VAR sales =&lt;BR /&gt;CALCULATE ( SUM ( Sold[Price] ), Sold[Status] = "Sold" )&lt;BR /&gt;VAR cancels =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUM ( Sold[Price] ),&lt;BR /&gt;Sold[Status] = "Canceled",&lt;BR /&gt;ALL ( Sold ),&lt;BR /&gt;Sold[Cancelation Date] = thismonth&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;sales - cancels&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, to get the right total, make the measure above and then use this measure in the visual.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sales Right Total = SUMX(VALUES(Sold[Sold Date]), [Total Sold])&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this works for you, please mark it as the solution.&amp;nbsp; Kudos are appreciated too.&amp;nbsp; Please let me know if not.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Pat&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 18:27:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1320379#M23214</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-08-24T18:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Measure based on 2 date column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1320466#M23215</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I forgot to include that measure:&lt;/P&gt;&lt;P&gt;You can download the file:&amp;nbsp;&lt;A href="https://1drv.ms/u/s!AmoScH5srsIYgYUuve7kVzXhoHQd7A?e=Wu176K" target="_blank" rel="nofollow noopener noreferrer"&gt;HERE&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_SUM =  SUM(Sold[Price]) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;________________________&lt;/P&gt;&lt;P&gt;Did I answer your question? Mark this post as a solution, this will help others!.&lt;/P&gt;&lt;P&gt;Click on the Thumbs-Up icon if you like this reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&lt;A href="https://www.youtube.com/channel/UCKwBEguA8IlBubIobaOormg?sub_confirmation=1" target="_blank"&gt;YouTube, &lt;/A&gt;&lt;A href="https://linkedin.com/in/fowmy" target="_blank"&gt;LinkedIn&lt;/A&gt;&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 19:01:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-based-on-2-date-column/m-p/1320466#M23215</guid>
      <dc:creator>Fowmy</dc:creator>
      <dc:date>2020-08-24T19:01:29Z</dc:date>
    </item>
  </channel>
</rss>

