<?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: Sales per customer that happened outside their subscription time in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-per-customer-that-happened-outside-their-subscription-time/m-p/3006005#M101709</link>
    <description>&lt;P&gt;You could create a measure like&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Purchases outside subscriptions =
VAR CustWithSub =
    FILTER (
        VALUES ( 'Customer'[Customer ID] ),
        NOT ISEMPTY ( RELATEDTABLE ( 'Subscription' ) )
    )
VAR CustWithoutSub =
    FILTER (
        VALUES ( 'Customer'[Customer ID] ),
        ISEMPTY ( RELATEDTABLE ( 'Subscription' ) )
    )
VAR CustWithDates =
    GENERATE (
        CustWithSub,
        VAR CustID = 'Customer'[Customer ID]
        VAR SubAStart =
            LOOKUPVALUE (
                'Subscription'[Start date],
                'Subscription'[Customer ID], CustID,
                'Subscription'[Type], "Subscription A",
                MAX ( 'Date'[Date] )
            )
        VAR SubAEnd =
            LOOKUPVALUE (
                'Subscription'[End date],
                'Subscription'[Customer ID], CustID,
                'Subscription'[Type], "Subscription A"
            )
        VAR SubBStart =
            LOOKUPVALUE (
                'Subscription'[Start date],
                'Subscription'[Customer ID], CustID,
                'Subscription'[Type], "Subscription B",
                MAX ( 'Date'[Date] )
            )
        VAR SubBEnd =
            LOOKUPVALUE (
                'Subscription'[End date],
                'Subscription'[Customer ID], CustID,
                'Subscription'[Type], "Subscription B"
            )
        VAR SubADates =
            DATESBETWEEN ( 'Date'[Date], SubAStart, SubAEnd )
        VAR SubBDates =
            DATESBETWEEN ( 'Date'[Date], SubBStart, SubBEnd )
        RETURN
            UNION (
                EXCEPT ( VALUES ( 'Date'[Date] ), SubADates ),
                EXCEPT ( VALUES ( 'Date'[Date] ), SubBDates )
            )
    )
VAR NumPurchasesWithoutSub =
    CALCULATE ( COUNTROWS ( 'Sales' ), CustWithoutSub )
VAR NumPurchasesWithSub =
    CALCULATE (
        COUNTROWS ( 'Sales' ),
        TREATAS ( CustWithDates, 'Customer'[Customer ID], 'Date'[Date] )
    )
RETURN
    NumPurchasesWithoutSub + NumPurchasesWithSub
&lt;/LI-CODE&gt;
&lt;P&gt;to give you the number of purchases. And then create a measure like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Num customers =
COUNTROWS (
    FILTER (
        VALUES ( 'Customer'[Customer ID] ),
        [Purchases outside subscriptions] &amp;gt; 1
    )
)
&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 06 Jan 2023 15:02:37 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2023-01-06T15:02:37Z</dc:date>
    <item>
      <title>Sales per customer that happened outside their subscription time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-per-customer-that-happened-outside-their-subscription-time/m-p/3005107#M101647</link>
      <description>&lt;P&gt;Hello Community!&lt;BR /&gt;&lt;BR /&gt;Im fairly new with DAX, and I am dying to get help with this problem!&lt;BR /&gt;&lt;BR /&gt;I am trying to find out:&lt;BR /&gt;&lt;BR /&gt;1. Distinct count of the customers who purchased Product A, OUTSIDE their subscription time.&lt;BR /&gt;2. Count of the purchases (Product A) they made OUTSIDE their subscription time&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;My data model is very simple:&lt;BR /&gt;&lt;BR /&gt;Customer table (relation &lt;STRONG&gt;1 - *&lt;/STRONG&gt; w/ CustomerID) Sales table (relation&amp;nbsp;&lt;STRONG&gt;* - 1 &lt;/STRONG&gt;w/Date) Date Table&lt;BR /&gt;Customer table (relation&amp;nbsp;&lt;STRONG&gt;1 - * &lt;/STRONG&gt;w/ CustomerID) Subscriptions table&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;One customer can have two different subscriptions on and off (SubscriptionA, SubscriptionB), which have starting date and ending date. Some are still active and they dont have an ending date.&lt;BR /&gt;At any time they can also make purchases (Product A) and Im interested to find out only those which have been made outside these subscription times. Note, that some customers have never been subscribers, only bought Product A. I need these as well.&lt;BR /&gt;&lt;BR /&gt;Hope I was clear with me explanation and someone has time to help with this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 11:21:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-per-customer-that-happened-outside-their-subscription-time/m-p/3005107#M101647</guid>
      <dc:creator>PowerStrang3r</dc:creator>
      <dc:date>2023-01-06T11:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sales per customer that happened outside their subscription time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-per-customer-that-happened-outside-their-subscription-time/m-p/3006005#M101709</link>
      <description>&lt;P&gt;You could create a measure like&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Purchases outside subscriptions =
VAR CustWithSub =
    FILTER (
        VALUES ( 'Customer'[Customer ID] ),
        NOT ISEMPTY ( RELATEDTABLE ( 'Subscription' ) )
    )
VAR CustWithoutSub =
    FILTER (
        VALUES ( 'Customer'[Customer ID] ),
        ISEMPTY ( RELATEDTABLE ( 'Subscription' ) )
    )
VAR CustWithDates =
    GENERATE (
        CustWithSub,
        VAR CustID = 'Customer'[Customer ID]
        VAR SubAStart =
            LOOKUPVALUE (
                'Subscription'[Start date],
                'Subscription'[Customer ID], CustID,
                'Subscription'[Type], "Subscription A",
                MAX ( 'Date'[Date] )
            )
        VAR SubAEnd =
            LOOKUPVALUE (
                'Subscription'[End date],
                'Subscription'[Customer ID], CustID,
                'Subscription'[Type], "Subscription A"
            )
        VAR SubBStart =
            LOOKUPVALUE (
                'Subscription'[Start date],
                'Subscription'[Customer ID], CustID,
                'Subscription'[Type], "Subscription B",
                MAX ( 'Date'[Date] )
            )
        VAR SubBEnd =
            LOOKUPVALUE (
                'Subscription'[End date],
                'Subscription'[Customer ID], CustID,
                'Subscription'[Type], "Subscription B"
            )
        VAR SubADates =
            DATESBETWEEN ( 'Date'[Date], SubAStart, SubAEnd )
        VAR SubBDates =
            DATESBETWEEN ( 'Date'[Date], SubBStart, SubBEnd )
        RETURN
            UNION (
                EXCEPT ( VALUES ( 'Date'[Date] ), SubADates ),
                EXCEPT ( VALUES ( 'Date'[Date] ), SubBDates )
            )
    )
VAR NumPurchasesWithoutSub =
    CALCULATE ( COUNTROWS ( 'Sales' ), CustWithoutSub )
VAR NumPurchasesWithSub =
    CALCULATE (
        COUNTROWS ( 'Sales' ),
        TREATAS ( CustWithDates, 'Customer'[Customer ID], 'Date'[Date] )
    )
RETURN
    NumPurchasesWithoutSub + NumPurchasesWithSub
&lt;/LI-CODE&gt;
&lt;P&gt;to give you the number of purchases. And then create a measure like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Num customers =
COUNTROWS (
    FILTER (
        VALUES ( 'Customer'[Customer ID] ),
        [Purchases outside subscriptions] &amp;gt; 1
    )
)
&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 06 Jan 2023 15:02:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-per-customer-that-happened-outside-their-subscription-time/m-p/3006005#M101709</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-01-06T15:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sales per customer that happened outside their subscription time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-per-customer-that-happened-outside-their-subscription-time/m-p/3006317#M101734</link>
      <description>&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt; Thank you SO SO MUCH for taking your time and helping me with this!!! &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;Let me try this on during the weekend and come back to you if it worked 100% &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 06 Jan 2023 18:01:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-per-customer-that-happened-outside-their-subscription-time/m-p/3006317#M101734</guid>
      <dc:creator>PowerStrang3r</dc:creator>
      <dc:date>2023-01-06T18:01:01Z</dc:date>
    </item>
  </channel>
</rss>

