+ Reply to Thread
Results 1 to 5 of 5

Conditional Weighted Averages - Take a weighted average of a set of data if it contains sp

  1. #1
    Registered User
    Join Date
    07-16-2019
    Location
    Boston
    MS-Off Ver
    Latest
    Posts
    3

    Conditional Weighted Averages - Take a weighted average of a set of data if it contains sp

    Hi all - thanks in advance for your help. As my username says, I am an excel noob, and struggling with even the google tutorials on these topics. I attempted a simple array "averageif" formula - but receiving errors, and just a test case.

    There are 4 sheets, with screenshots provided below:

    1) Universe sheet - In this sheet, column C has all of my "industry codes" - and this extends all the way down 200 or so rows. Columns D - VJ are the companies (each cell has a unique ticker code) that is assigned to this code. Companies can exist in multiple industry codes.

    2) Raw Revenue - In this sheet, from 2000 - present, are quarterly revenue data points for each "ticker/company". Column A is the company ticker, D onwards are the data points

    3) Net Margin - In this sheet, I've calculated Net Margins for each company for each time series. Very similar sheet to Screenshot #2

    4) Averaging sheet - In this sheet, I would like to take a revenue weighted average of the net margins shown in screenshot 3 - by industry code, as shown in screenshot 1.

    All industry codes are shown in column C. A list of the companies in each code is in the first sheet. All the Revenue data is in screenshot 2. screenshot 3 has the net margin percentages. Basically, for each time period that has a revenue data point, take a revenue weighted average of the netmargin percentage.

    I attempted in screenshot 4 to just take a simple averageif of the netmargin, which is a simple average.

    Questions: 1) Why do I have so many div/0? The array formula does give me a few good data sets, but any idea why have so many div/0? I thought the averageif formula excludes missing data points?
    2) How do I take a revenue weighted average as mentioned above? "
    All industry codes are shown in column C. A list of the companies in each code is in the first sheet. All the Revenue data is in screenshot 2. screenshot 3 has the net margin percentages. Basically, for each time period that has a revenue data point, take a revenue weighted average of the netmargin percentage."

    Here is the formula i dragged out and array ctrl shift enter on in sheet 4: =AVERAGEIF('Calculated "Net Margin"'!$A$3:$A$3791,'BICS & Equities Clean H'!$D3:$ZZ3,'Calculated "Net Margin"'!AZ$3:AZ$200)

    1.png
    2.png
    3.png
    4.png

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,387

    Re: Conditional Weighted Averages - Take a weighted average of a set of data if it contain

    Welcome to the forum.

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    07-16-2019
    Location
    Boston
    MS-Off Ver
    Latest
    Posts
    3

    Re: Conditional Weighted Averages - Take a weighted average of a set of data if it contain

    Hello!
    Thanks for the quick response!

    Sample sheet is attached.
    Last sheet titled "Mock Results" have what my desired results are - are a revenue weighted average by time period

    The sample data set is representative, but i truncated and removed a lot of the data.

    hi all,
    Kindly see the post below. there is a link to a google file with the sample excel.
    Last edited by excelnoob33; 07-16-2019 at 02:51 PM.

  4. #4
    Registered User
    Join Date
    07-16-2019
    Location
    Boston
    MS-Off Ver
    Latest
    Posts
    3

    Re: Conditional Weighted Averages - Take a weighted average of a set of data if it contain

    EDIT: I can't seem to upload any files
    whether XLSB, or zip

    here is a google link to the file:
    ok update, i can't even post a google link... here is the file below - sorry for the work around.

    drive DOT google DOT com/file/d/1woezMtXQ2Hv7vPoeyoaB73OKkvgNxsKQ/view?usp=sharing

  5. #5
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,869

    Re: Conditional Weighted Averages - Take a weighted average of a set of data if it contain

    Perhaps you could produce a small sample file from one or two industries, say office supplies and seismic surveying as they only appear to have 3 ticker codes each. The raw revenue and net margin sheets would populate using the existing formulas for each. On the averaging sheet manually type in the results that you would expect to see for a few quarters, say from 1Q2000:4Q2001. Unless it is very obvious as to how the weighted averages are derived, also include an explanation of the math involved so that we can attempt to replicate using Excel formulas/code.
    The remarks concerning AVERAGEIF from the support.office.com site states: "If range is a blank or text value, AVERAGEIF returns the #DIV0! error value."
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Project assistance-Web Data and weighted averages
    By Bobcatbuckface in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-26-2019, 03:30 PM
  2. Weighted Average Function for Series Weighted by Increments of 1
    By kratsexcel in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-05-2018, 11:38 AM
  3. Replies: 0
    Last Post: 02-15-2018, 03:04 AM
  4. Conditional weighted average
    By bdavila in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-30-2017, 01:58 PM
  5. Need help with weighted conditional averages
    By culb in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-03-2015, 02:00 PM
  6. Weighted Average IF (sumproduct conditional)
    By Leopold2000 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-16-2013, 03:27 PM
  7. Conditional weighted average
    By saturnexcel in forum Excel General
    Replies: 8
    Last Post: 04-20-2009, 04:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1