• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Median, Mode calculation and dynamic ranges for formulae

rajdeep

New Member
Hello,

I'm a regular follower of Chandoo & I thank all contributors for my improved Excel Skills. Recently I faced a problem in Excel and would request your inputs to solve it in a simple way.

Our company has 70 products that are sold across 50 states in US through 1000s of agents who charge different rates (within a range) to sell each product. I've been asked to run an analysis to identify cost of agent across each state, each product over the last quarter month-on-month. Specifically, I've identified min, max, average for all of these by creating a simple pivot table. I got stuck while calculating median and mode. These options aren't available on pivot table and I have to work on the raw data.

What I have tried: Sorted data by product code (SKU)& State. At the change of every state under every SKU, I've manually added two rows to select the above number of orders and calculate median and mode. It is painful to do this 70*50 times approximately. That too when the source/range for the formula keeps changing. Is there a simple way to calculate the median and mode when no. of orders keep changing from state to state and product to product. Is there a way to let a formula dynamically select a range to calculate a value? Can this be done without VB?
 
Don't need to define the range, we can have the formula just look at the cells we care about. Something like the array* formula:

=MEDIAN(IF(($A$2:$A$10=A2)*($B$2:$B$10=B2),$C$2:$C$10))

would give the median for all the numbers in col C where col A = A2 and col B = B2, ie State and SKU were the same. Replace MEDIAN w/ MODE to get the other formula.


*Array formulas must be confirmed using Ctrl+Shift+Enter, not just Enter.
 
You could also press F5-->special-->blanks-->ok. Then enter the formula you want then press Ctrl+enter. This will do whatever formula you did in the first cell to all blank cells.

or

if you file already has formulas. You could F5--special-->--formulas-->ok, then do the same thing as mentioned above.
 
Don't need to define the range, we can have the formula just look at the cells we care about. Something like the array* formula:

=MEDIAN(IF(($A$2:$A$10=A2)*($B$2:$B$10=B2),$C$2:$C$10))

would give the median for all the numbers in col C where col A = A2 and col B = B2, ie State and SKU were the same. Replace MEDIAN w/ MODE to get the other formula.


*Array formulas must be confirmed using Ctrl+Shift+Enter, not just Enter.
Thanks, this suggestion helped me a lot in completing a key deliverable.
 
Back
Top