Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mgreez
Advocate II
Advocate II

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 6
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@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?

 

Hi,

My solution is completely dynamic.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur 

 

For example, if I filter any of the AccountIDs out, the results aren't going to refresh based on the new subset of data.

 

Another example would be where I have a Time dimension and wanted to filter on different Time Periods.

 

Hi,

Please illustrate.  My solution will work.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
HotChilli
Super User
Super User

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

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.