<?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: Dax Measure to sort most diverse payment terms in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315919#M23112</link>
    <description>One more thing... I think the best way to achieve what you want is not to rank by the weighted average term but by the weighted average term spread. That means you should calculate the standard deviation (or absolute standard deviation) of terms where the probabilistic measure would be the proportions of payments. Through this you would really be measuring payment spread, not an averaged term.</description>
    <pubDate>Fri, 21 Aug 2020 23:08:35 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-08-21T23:08:35Z</dc:date>
    <item>
      <title>Dax Measure to sort most diverse payment terms</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315608#M23094</link>
      <description>&lt;P&gt;Hello. I am trying to create a measure to use in a matrix to sort the most diverse supplier for payment terms. To clarify when i mean most diverse payment terms my goal is to rank suppliers that have more diverse payment terms(by invoice amount weighted). Quick example- i would sort a supplier with 4 payments terms(25% invoice amount each) ranked higher than payment terms also with 4 payment terms but a breakdown of (80%, 10%, 5%,5% for invoice amount totals).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Supplier Name&lt;/TD&gt;&lt;TD&gt;Invoice Amount&lt;/TD&gt;&lt;TD&gt;Payment Terms&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;60 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;3400&lt;/TD&gt;&lt;TD&gt;45 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;3200&lt;/TD&gt;&lt;TD&gt;30 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;1700&lt;/TD&gt;&lt;TD&gt;30 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;1700&lt;/TD&gt;&lt;TD&gt;60 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;1700&lt;/TD&gt;&lt;TD&gt;45 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;1500&lt;/TD&gt;&lt;TD&gt;10 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;1700&lt;/TD&gt;&lt;TD&gt;90 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;1500&lt;/TD&gt;&lt;TD&gt;60 Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;30 Days&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;A Payment Term breakdown: 30 Days-45%,60 Days-7%, 45 Days-48%, 30 Days-45%&lt;/P&gt;&lt;P&gt;B&amp;nbsp;Payment Term breakdown: 60 Days-50%, 30 Days-50%&lt;/P&gt;&lt;P&gt;C Payment Term breakdown:&amp;nbsp;30 Days-6% , 60 Days-22%, 45 Days-25%, 10 Days-22%, 90 Days-25%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would rank these suppliers in diversity from C-rank 1, A-rank 2, and B rank 3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you have any ideas. Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 18:40:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315608#M23094</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-21T18:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Measure to sort most diverse payment terms</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315630#M23095</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;- Not sure what the percentages have to do with it, seems like you could do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure 2 = 
    VAR __Supplier = MAX('Table (8)'[Supplier Name])
    VAR __Table = SUMMARIZE(ALL('Table (8)'),[Supplier Name],"Count",COUNTROWS(DISTINCT('Table (8)')))
    VAR __Table1 = ADDCOLUMNS(__Table,"Rank",RANKX(__Table,[Count],,DESC))
RETURN
    MAXX(FILTER(__Table1,[Supplier Name]=__Supplier),[Rank])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PBIX attached below sig, you want Table 8, Page 8&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 18:55:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315630#M23095</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-08-21T18:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Measure to sort most diverse payment terms</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315646#M23098</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Did not understand this part &lt;EM&gt;"&amp;nbsp;i would sort a supplier with 4 payment terms(25% invoice amount each) ranked higher than payment terms also with 4 payment terms but a breakdown of (80%, 10%, 5%,5% for invoice amount totals). "&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;If you need to rank based on number of payment terms options then how to apply the % that you need to add as a&amp;nbsp; weight:&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;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 19:08:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315646#M23098</guid>
      <dc:creator>Fowmy</dc:creator>
      <dc:date>2020-08-21T19:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Measure to sort most diverse payment terms</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315661#M23100</link>
      <description>&lt;P&gt;Sorry a little confused on what you mean. Yes i would like to weight payment terms by the invoice amount. I am more concerned with payment terms that are diverse with invoice amounts weighted than just pure count. To clarify my previous section:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IF Supplier A has $100,000 in payment combined, but each payment term(count of 4) each payment term would have a total of $25,000 . I would consider supplier A more diverse than Supplier B that also has $100,000 with &lt;U&gt;5 payment terms&lt;/U&gt;(breakdown 60 days=80,000, 40 days=10,000, 30 days=5,000, 10 Days=4,000, 2 days=1,000) b/c the distribution across payment terms is more spread out compared to Supplier B having 80% of invoices in one payment term category.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially I want to prioritize suppliers that have the most diversity in payment terms by invoice amount. I'm more interested in suppliers that are more divided(invoice amount weighted) than suppliers that have more payment types but only 1 or 2 payments types comprise the majority of invoices.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 19:19:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315661#M23100</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-21T19:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Measure to sort most diverse payment terms</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315668#M23101</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;. Thank you for the help. I can seem to get the last line:&lt;/P&gt;&lt;PRE&gt; MAXX(FILTER(__Table1,[Supplier Name]=__Supplier),[Rank])&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;the [Supplier Name] does not seem to work it only allows me to put a table. Additionally I clarified below i wanted to weight payment terms by invoice amount. I posted a clarification below. Any help on how to change the measure to be spend weighted would be much appreciated. &amp;nbsp;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 19:21:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315668#M23101</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-21T19:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Measure to sort most diverse payment terms</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315764#M23103</link>
      <description>&lt;DIV&gt;&lt;FONT&gt;Hi there.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;I've analyzed the case you've shown and the ranking is different. Most diverse terms has C, then B and then A. Here's a bit of theory.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;You say you want to rank them by terms weighted by payments. So, let's consider just one supplier. They have a vector of term-paments: &lt;/FONT&gt;&lt;FONT&gt;( (T(1), P(1)), (T(2), P(2)),...,(T(n), P(n)) ).&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Weighted Term (by Payment) is defined as:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; sum over i (i=1,...,n): T(i) * P(i)&lt;BR /&gt;WT =&amp;nbsp; --------------------------------&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; sum over i (i=1,...,n): P(i)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;If you carry out this calculation over the three suppliers, you'll get:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;WT(A) = 39.29&lt;BR /&gt;WT(B) = 45.00&lt;BR /&gt;WT(C) = 50.95&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Hence, C &amp;gt; B &amp;gt; A. Which is not what you claim.&lt;/FONT&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Aug 2020 20:47:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315764#M23103</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-21T20:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Measure to sort most diverse payment terms</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315771#M23104</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;- Not sure what you are doing, it works in the PBIX I sent, attaching again.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 20:57:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315771#M23104</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-08-21T20:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Measure to sort most diverse payment terms</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315795#M23105</link>
      <description>&lt;P&gt;This is an implementation of the algorithm I've pasted before. Have not checked it, so it's your turn.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Here's a measure that uses the weighted
// term (by payment):

[Supplier Weighted Terms] =
if( HASONEVALUE( T[Supplier Name] ),
    
    var __numerator =
        SUMX(
            T,
            T[Invoice Amount] * T[Payment Terms]
        )
    var __denominator = sum( T[Invoice Amount] )
    return
        DIVIDE( __numerator, __denominator )
    
)

[Supplier Rank] = // 1 means highest [Weighted Terms]
if( HASONEVALUE( T[Supplier Name] ),
    
    var __suppliersToRankOver =
        CALCULATETABLE(
            VALUES( T[Supplier Name] ),
            ALLSELECTED( T )
        )
    var __rank =
        RANKX(
            __suppliersToRankOver,
            [Supplier Weighted Terms],
            ,
            DESC,
            DENSE
        )
    return
        __rank
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that the field T[Payment Terms] must be an int, not text, for the above to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 22:45:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315795#M23105</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-21T22:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Measure to sort most diverse payment terms</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315919#M23112</link>
      <description>One more thing... I think the best way to achieve what you want is not to rank by the weighted average term but by the weighted average term spread. That means you should calculate the standard deviation (or absolute standard deviation) of terms where the probabilistic measure would be the proportions of payments. Through this you would really be measuring payment spread, not an averaged term.</description>
      <pubDate>Fri, 21 Aug 2020 23:08:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1315919#M23112</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-21T23:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Dax Measure to sort most diverse payment terms</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1316183#M23118</link>
      <description>&lt;LI-CODE lang="csharp"&gt;// Here's a different measure to rank your
// suppliers by. I think it's more relevant
// than the weighted average. By the way,
// the weighted average is just the expected
// value of a random variable (i.e., terms) where
// the probabilistic measure is just the proportion
// of payments. Of course, it is just another
// interpretation. In the same vein, you can
// define the SPREAD of the variable with respect
// to this probabilistic measure, the spread
// being the standard deviation w.r.t. the same
// measure. It could also be the absolute standard
// deviation. I'll give you formulae for both
// interpretations. If you have any background in
// probability, you should understand what it
// all means.

// First, let's calculate the standard deviation
// of terms w.r.t. the prob measure of payment
// proportions. The below is just a way of
// coding the standard deviation:
//
// |sum over i: P(i) * (T(i))^2                     |^(1/2)
// |--------------------------- - ([Weighted Avg])^2|
// |sum over i: P(i)                                |
//

WT Spread = 
if( HASONEVALUE( T[Supplier Name] ),    
    var __wt = [Supplier Weighted Terms]
    var __numerator =
        SUMX(
            T,
            T[Invoice Amount] * (T[Payment Terms])^2
        )
    var __denominator = sum( T[Invoice Amount] )
    return
        SQRT(
            DIVIDE( __numerator, __denominator )
            - (__wt)^2
        )
)

// Second, you can calculate the absolute standand
// deviation of terms.

WT Spread (ABS) = 
if( HASONEVALUE( T[Supplier Name] ),    
    var __wt = [Supplier Weighted Terms]
    var __numerator =
        SUMX(
            T,
            T[Invoice Amount]
            * ABS(T[Payment Terms] - __wt)
        )
    var __denominator = sum( T[Invoice Amount] )
    return
        DIVIDE( __numerator, __denominator )
)

// Both measures above quantify the spread of terms
// around [Supplier Weighted Average]. Sinci you want
// to have a measure of spread, as you mention, I think
// the above should be more relevant. [Supplier Weighted Average]
// measures the mean term after which you'll regain all
// your payments.&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 22 Aug 2020 09:48:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-Measure-to-sort-most-diverse-payment-terms/m-p/1316183#M23118</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-22T09:48:42Z</dc:date>
    </item>
  </channel>
</rss>

