Forum Discussion

mgreez's avatar
mgreez
Advocate II
6 years ago

Biotech Deciling is Different - DAX HELP

Deciling Accounts by Sales in Biotech is a bit different than the typical n-tile type Deciling (breaking into 10 even groups), but is weighted based on the relative size of the Sales.

 

The process in Excel is first sorting the Accounts largest to smallest by Sales, then calculating the % of total, then calculating the running total of the % of total, then performing a vlookup (with TRUE) on the running total metric.

 

I'm struggling with creating a DAX measure out of this!  Please help!

 

Here are two tables:

 

Account Sales

AccountIDSales% of TotalCumulative % of TotalDecile
36241720007.6%8%10
42917819507.4%15%9
83272919507.4%22%8
46711019007.2%30%8
97838318787.1%37%7
45026518006.8%44%6
14354416006.1%50%6
87999915005.7%55%5
82391215005.7%61%4
32347413004.9%66%4
44337312004.5%70%3
33246912004.5%75%3
26734811004.2%79%3
78292310003.8%83%2
9674479003.4%86%2
5590468503.2%90%2
6224908003.0%93%1
5864947502.8%95%1
2036536002.3%98%1
7127726002.3%100%1

 

 

Lookup table:

Lookup ValueDecile
010
0.19
0.28
0.37
0.46
0.55
0.64
0.73
0.82
0.91
10

 

6 Replies

  • HotChilli's avatar
    HotChilli
    Community Champion

    I am unsure as to whether you are asking for the decile measure or everything apart from the AccountID and Sales.

    If it's everything here goes:

    In Power Query, order the table by Sales descending.

    Add an Index Column from 1.

    Close and Apply.

    Create 3 columns as follows:

    2Col% of Tot = AccountSales[Sales]/ CALCULATE(SUM(AccountSales[Sales]), ALL(AccountSales))
    
    2Cumu%Total = CALCULATE(SUM(AccountSales[2Col% of Tot]), FILTER(AccountSales, AccountSales[Index] <= EARLIER(AccountSales[Index])))
    
    2Decile = CALCULATE(MIN(TableLookup[Decile]), FILTER(TableLookup,TableLookup[Lookup Value] < AccountSales[2Cumu%Total] )  )

     

    You can format the columns to show the appropriate decimal places and as percent

     

    • mgreez's avatar
      mgreez
      Advocate II

      Ashish_Mathur HotChilli 

      Thank you both for taking the time to help!

       

      Ultimately, I would love for this to be dynamic, meaning that I would be able to select different Time Periods and they decile would automatically update.  In that case, would I be able to start with a calculated table as my VAR in the measure?  Would I be able to do the sorting of a calculated table within a measure?