Sum of bottom 20% values

arnabmit

New Member
Joined
Mar 28, 2009
Messages
27
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I was trying to get the sum of the bottom 20% values, then show it by year. However, the DAX returned the total value.

Code:
Bottom 20% Values =
VAR BV = ROUND(COUNTROWS(Sheet1) * 0.2,0)
VAR DR = RANKX(ALL(Sheet1),CALCULATE(SUM(Sheet1[Value])),,DESC,Skip)
RETURN
IF(DR <= BV, CALCULATE(SUM(Sheet1[Value])),BLANK())

Then as per some suggestion, I introduced another set of iterators. This time, it returned the sum of bottom 20%. However, it still was not working properly when trying to group by years.

Code:
Bottom 20% Values =
VAR BV = ROUND(COUNTROWS(ALL('Sheet')) * 0.2,0)

RETURN
SUMX(
    'Sheet',
    VAR DR = RANKX(ALL('Sheet'),CALCULATE(SUM('Sheet'[Value])),,ASC,Skip)
    RETURN IF(DR<=BV,'Sheet'[Value],0)
)

For example, if I am trying to check for say 60% instead of 20%, and group them by year, The ranking is not working for the group, but the entire range.

arnabmit_0-1654951281779.png


Can anyone please help me understand what I am doing wrong? Thanks in advance!

PBIX
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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