Median If across workbook with several sheets

VCarr

New Member
Joined
Mar 20, 2011
Messages
3
Hi,
I have a workbook with several sheets. In each sheet, I have three columns: Column A = name; Columns B and C are dates.

I need a formula that says if column A (in any sheet) = TEXT, then calculate the median number of days between Columns B and C (again taking each sheet into account). Is this possible?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
If, for example, you have three worksheets, and assuming that Column B contains the start date, and Column C contains the end date, try the following formula that needs to be confirmed with CONTROL+SHIFT+ENTER...

=MEDIAN(IF(Sheet1!A2:A100="Text",Sheet1!C2:C100-Sheet1!B2:B100),IF(Sheet2!A2:A100="Text",Sheet2!C2:C100-Sheet2!B2:B100),IF(Sheet3!A2:A100="Text",Sheet3!C2:C100-Sheet3!B2:B100))

Adjust the ranges, accordingly.
 
Last edited:
Upvote 0
Hi, I have used the same principle as above, however the value does not seem to be correct. I have two sheets, each containing panel data. Sheet 1 contains years 2000-2009 for each firm ID, Sheet 2 contains the years 2010-2012 for each firm ID. Each firm ID is assigned an industry code (which is of course constant over time). Column F is the column I want to get the median for. I made a new sheet where each industry code is listed. Next to the industry code, I entered the following formula:
=MEDIAN(IF(Blatt1!$C$2:$C$920869=A2;Blatt1!$F$2:$F$920869);IF(Blatt1!$B$2:$B$920869=$B$1;Blatt1!$F$2:$F$920869))
Column C of each sheet contains the industry code, column B the year. So the if-conditions in this array-formula are: year is as in $B$1, industry as in A2. Entering this as an array-formula, I get the value 0.757741 . To check whether the result is correct, I filtered the original dataset, only showing the year 2000 and the desired industry code. Taking the median of the values in column F then, I get 0.744019. How can this error occur?
 
Upvote 0
How did you calculate the MEDIAN of the filtered values? If you just used the MEDIAN function on the filtered results, the function doesn't respect the filter. It will include the hidden filtered values.
 
Upvote 0
How did you calculate the MEDIAN of the filtered values? If you just used the MEDIAN function on the filtered results, the function doesn't respect the filter. It will include the hidden filtered values.

I was aware of that, so after filtering, I copy-pasted the values out of the filtered panel into a new sheet and then ran the median formula...
 
Upvote 0
Hi, I have used the same principle as above, however the value does not seem to be correct. I have two sheets, each containing panel data. Sheet 1 contains years 2000-2009 for each firm ID, Sheet 2 contains the years 2010-2012 for each firm ID. Each firm ID is assigned an industry code (which is of course constant over time). Column F is the column I want to get the median for. I made a new sheet where each industry code is listed. Next to the industry code, I entered the following formula:
=MEDIAN(IF(Blatt1!$C$2:$C$920869=A2;Blatt1!$F$2:$F$920869);IF(Blatt1!$B$2:$B$920869=$B$1;Blatt1!$F$2:$F$920869))
Column C of each sheet contains the industry code, column B the year. So the if-conditions in this array-formula are: year is as in $B$1, industry as in A2. Entering this as an array-formula, I get the value 0.757741 . To check whether the result is correct, I filtered the original dataset, only showing the year 2000 and the desired industry code. Taking the median of the values in column F then, I get 0.744019. How can this error occur?

For the one sheet, try...

=MEDIAN(IF(Blatt1!$C$2:$C$920869=A2;IF(Blatt1!$B$2:$B$920869=$B$1;Blatt1!$F$2:$F$920869)))

For both sheets, try...

=MEDIAN(IF(Blatt1!$C$2:$C$920869=A2;IF(Blatt1!$B$2:$B$920869=$B$1;Blatt1!$F$2:$F$920869)),IF(Blatt2!$C$2:$C$920869=A2;IF(Blatt2!$B$2:$B$920869=$B$1;Blatt2!$F$2:$F$920869)))

Note that both formulas need to be confirmed with CONTROL+SHIFT+ENTER.

Hope this helps!
 
Upvote 0
sry, may i ask u all know hw to calculate median via VBA Coding in macro? i need a coding to calculate median on my excel sheet and then put in a new column.....
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,753
Members
452,940
Latest member
rootytrip

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