<?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 DAX: Top Customer by Sales on a specific date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1752136#M36518</link>
    <description>&lt;P&gt;Hi, i am trying to create a matrix table that shows the top 1 customer by the purchase date. I have created the below statements that returns the max date with sales (there is not always sales on every day) and then a sum statement filtering on this max date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when i create a matrix and try to filter by this statement it returns all the sales instead of just the sales on that day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know a statement i can write to just filter on the Top 1 customer by NetValue by the max date i created? I created similar tables for month and week...however this was just using the filter tab.&amp;nbsp;&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;PRE&gt;&lt;SPAN&gt;MaxDate_withSales = CALCULATE(MAX(Finance_Sales[PurchaseDate]),Finance_Sales[NetValueBasedOnCommitment]&amp;gt;0)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Daily_Order_Value = CALCULATE(SUM(Finance_Sales[NetValueBasedOnCommitment]),DATESBETWEEN(Finance_Sales[PurchaseDate],[MaxDate_withSales],[MaxDate_withSales]))&lt;/PRE&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 29 Mar 2021 14:22:06 GMT</pubDate>
    <dc:creator>adam_mac</dc:creator>
    <dc:date>2021-03-29T14:22:06Z</dc:date>
    <item>
      <title>DAX: Top Customer by Sales on a specific date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1752136#M36518</link>
      <description>&lt;P&gt;Hi, i am trying to create a matrix table that shows the top 1 customer by the purchase date. I have created the below statements that returns the max date with sales (there is not always sales on every day) and then a sum statement filtering on this max date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when i create a matrix and try to filter by this statement it returns all the sales instead of just the sales on that day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know a statement i can write to just filter on the Top 1 customer by NetValue by the max date i created? I created similar tables for month and week...however this was just using the filter tab.&amp;nbsp;&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;PRE&gt;&lt;SPAN&gt;MaxDate_withSales = CALCULATE(MAX(Finance_Sales[PurchaseDate]),Finance_Sales[NetValueBasedOnCommitment]&amp;gt;0)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;Daily_Order_Value = CALCULATE(SUM(Finance_Sales[NetValueBasedOnCommitment]),DATESBETWEEN(Finance_Sales[PurchaseDate],[MaxDate_withSales],[MaxDate_withSales]))&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 29 Mar 2021 14:22:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1752136#M36518</guid>
      <dc:creator>adam_mac</dc:creator>
      <dc:date>2021-03-29T14:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Top Customer by Sales on a specific date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1752193#M36521</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="273608" data-lia-user-login="adam_mac" class="lia-mention lia-mention-user"&gt;adam_mac&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it is OK with you, please share your sample pbix file, then I can try to look into it to come up with more accurately written measures.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;FONT face="”times" color="”#000000”"&gt;&lt;EM&gt;&lt;STRONG&gt;Hi, My name is Jihwan Kim. &lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="”times" color="”#000000”"&gt;&lt;EM&gt;&lt;STRONG&gt;If this post helps, then please consider accept it as the solution to help other members find it faster.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 15:05:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1752193#M36521</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2021-03-29T15:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Top Customer by Sales on a specific date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1752200#M36522</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp;unfortunately this wont be possible as it contains confidential customer data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 15:07:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1752200#M36522</guid>
      <dc:creator>adam_mac</dc:creator>
      <dc:date>2021-03-29T15:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Top Customer by Sales on a specific date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1752491#M36543</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Assume that the field Customer Name from
// the dimension Customers has been dropped
// on the canvass of the table/matrix visual
// together with all the accompanying measures
// or attributes.

// This measure will return 1 for the customer(s)
// that have the highest order value on the last
// date with sales. The last day with sales is 
// RELATIVE to the last day visible in the current
// context. Of course, this measure honors all the other
// existing filters.

[Is Top Customer Within Max Sales Date?] =
var vOneCustomerVisible = HASONEVALUE( Customers[CustomerID] )
var vLastVisibleDay = MAX( Dates[Date] )
var vLastDayWithSales =
    // vLastDayWithSales is dependent on the selections
    // you've made in all dimensions. So, if there are
    // 3 customers selected only, the last sales day will be
    // the last sales day for those 3 customers. This will
    // most likely change if you select more customers or
    // have no filters on customers at all. This, of course,
    // can be changed do give you the absolute last sales
    // day but it's not clear from your description what the
    // last sales day should be.
    MAXX(
        // Dates must be a date table marked
        // as a date table in the model.
        CALCULATETABLE(
            SUMMARIZE(
                Sales, // fact table
                Dates[Date]
            ),
            Dates[Date] &amp;lt;= vLastVisibleDay
        ),
        Dates[Date]
    )
var vIsBestCustomer =
    if( vOneCustomerVisible,
        var vCurrentCustomer = SELECTEDVALUE( Customers[CustomerID] )
        var vBestCustomers =
            SELECTCOLUMNS(
                TOPN(1,
                    ALLSELECTED( Customers ),
                    CALCULATE(
                        // [Order Value] is the basic measure
                        // by which you want to order customers.
                        [Order Value], 
                        Dates[Date] = vLastDayWithSales
                    ),
                    DESC
                ),
                "@BestCustomerID",
                    Customers[CustomerID]
            )
        return
            vCurrentCustomer in vBestCustomers
    )
return
    1 * vIsBestCustomer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 17:21:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1752491#M36543</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-29T17:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Top Customer by Sales on a specific date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1753981#M36599</link>
      <description>&lt;P&gt;thanks&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;, are you able to adapt this code so that sales day is absolute? Last sales day should equal where Order value &amp;lt;&amp;gt; zero i.e. where order value is greater than zero.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 08:51:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Top-Customer-by-Sales-on-a-specific-date/m-p/1753981#M36599</guid>
      <dc:creator>adam_mac</dc:creator>
      <dc:date>2021-03-30T08:51:26Z</dc:date>
    </item>
  </channel>
</rss>

