PowerPivot percentiles

Viceroy369

New Member
Joined
Jan 7, 2013
Messages
25
Hello,

I've looked at a number of different posts from bloggers about finding a workaround for the percentile feature in DAX.

I am trying to calculate a dynamic percentile measure that correctly calculates the right Xth percentile of price for a given year and/or month. For example, if I have 2007, 2008, 2009, etc. in my pivot table, then I would like a percentile formula to show me the correct 5th, 10th, 15th, etc. percentile for that year. Ditto if I add month (although right now, I would be happy to get the year part working!)

Using combinations of a couple of posts on this topic, I have managed to create measures that work for the entire data set. However, they do not work for subsets. For example, my 5th percentile measure correctly calculates the 5th percentile of the entire price column of my table, but unlike other measures it does not adjust to context when I pivot this measure against, say, YEAR. The grand total will show the correct 5th percentile but the result for each individual year will be meaningless.

I am new to PowerPivot and am at a loss about how to do this. Any assistance would be greatly appreciated!

-------------------
Table: My data table (ZE_AB_pool_price) has several columns: OPR_DATE, OPR_HOUR, PRICE, PRICE_BIN, LOOKUP_HOUR, LOOKUP_DATE, VOLATILITY, LN_HOURLY, MONTH, and YEAR. Some of these are calculated and others are imported directly from an Oracle database. Each row in the table has a unique OPR_DATE and OPR_HOUR pair (i.e. there is one record for every hour).

Current measures (5th percentile):
Step 1: Calculate the rank of all items in my table:
rank:=rankx( ALL(ZE_AB_pool_price), [sum_price],,1)

Step 2: Calculate the rank corresponding to the 5th percentile:
Rank2_5:=calculate ( (countrows (ZE_AB_pool_price)-1)*5/100+1, all(ZE_AB_pool_price))

Step 3: Calculate the data value corresponding to the rank in Step 2. This is the upper percentile.
Up_5:=maxx (filter (ZE_AB_pool_price, [rank]<= roundup ((count([PRICE])-1)*5/100+1,0)),[PRICE])

Step 4: Caculate the data value corresponding to the rank in Step 2. This is the lower percentile.
Down_5:=maxx( filter (ZE_AB_pool_price, [rank]<= int((count([PRICE])-1)*5/100+1)),[PRICE])

Step 5: Perform a linear interpolation to find the correct 5th percentile value.
Percentile_5_2:=[Down_5]+ ([Up_5]-[Down_5])* ([Rank2_5]-rounddown([Rank2_5],0))

I used these two posts as sources. It appears the second post has an example of what I want to do but I couldn't figure out how to adapt it to my table structure.

Creating Accurate Percentile Measures in DAX – Part I « PowerPivotPro
Creating Accurate Percentile Measures in DAX – Part II « PowerPivotPro

Statastizard: PowerPivot Percentile DAX Formula
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Using PowerPivot / DAX, I think you should be able to return the percentiles in your pivot table using these steps. In this example I want to rank "ID" by whatever values I've selected in the pivot table.

____________________________________

Step 1:

Create a rank measure, e.g.,:

Rank:=IF(NOT(ISBLANK([Average Value])),RANKX(ALLSELECTED(Facts[ID]),[Average Value],,DESC,Dense),BLANK())

Step 2:

Create a measure to count the unique entries included in that ranking set, e.g.:

Unique IDs in Selection:=CALCULATE(DISTINCTCOUNT(Facts[ID]),ALLSELECTED(Facts[ID]))

Step 3:

Create a percentile measure:

Percentile:=[Rank]/[Unique Values in Selection]


____________________________________________


These two links explain the above steps in more detail.




#PowerPivot #DAX #Percentiles #Rank #Measures
 
Upvote 0
Try this - PERCENTILEX.INC(ALLSELECTED(Facts[ID]),SUMX(ALLSELECTED(Facts[Period]),[Sum Values]),[Percentile Definition])
 

Attachments

  • 1576195699542.png
    1576195699542.png
    17.5 KB · Views: 91
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,520
Members
448,968
Latest member
Ajax40

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top