calculate the weighted average
-
I sort of need to calculate the average of all the averages in a report. I have no clue how to do this, but I do have data. Do I have enough data here to do this, and perhaps some help with the formula I saw a couple of examples, but wow it looked so complex. http://study.com/academy/lesson/calculating-weighted-average-method-formula-example.html[^]
If (sCIR.Length > 0) Then
For idx As Integer = 0 To sCIR.Length - 1rs\_DataRow = rs\_Table.NewRow() rs\_DataRow(0) = sCIR(idx).FITEMNO rs\_DataRow(1) = sCIR(idx).FDESCRIPT rs\_DataRow(2) = sCIR(idx).FSHIPQTY rs\_DataRow(3) = sCIR(idx).FCOST rs\_DataRow(4) = sCIR(idx).FPRICE rs\_DataRow(5) = sCIR(idx).FAMOUNT rs\_DataRow(6) = sCIR(idx).FMARGIN\_PERCENT rs\_DataRow(7) = sCIR(idx).FMARGIN\_PROFIT 'Add up the total cost value m\_totalCost += sCIR(idx).FCOST \* sCIR(idx).FSHIPQTY 'Add up the total price value m\_totalPrice += sCIR(idx).FPRICE \* sCIR(idx).FSHIPQTY 'Calculate the average margin of all the items 'm\_avgMarkup += 'Add up the total margin value m\_totalMargin += sCIR(idx).FMARGIN\_PROFIT rs\_Table.Rows.Add(rs\_DataRow) Next End If
-
I sort of need to calculate the average of all the averages in a report. I have no clue how to do this, but I do have data. Do I have enough data here to do this, and perhaps some help with the formula I saw a couple of examples, but wow it looked so complex. http://study.com/academy/lesson/calculating-weighted-average-method-formula-example.html[^]
If (sCIR.Length > 0) Then
For idx As Integer = 0 To sCIR.Length - 1rs\_DataRow = rs\_Table.NewRow() rs\_DataRow(0) = sCIR(idx).FITEMNO rs\_DataRow(1) = sCIR(idx).FDESCRIPT rs\_DataRow(2) = sCIR(idx).FSHIPQTY rs\_DataRow(3) = sCIR(idx).FCOST rs\_DataRow(4) = sCIR(idx).FPRICE rs\_DataRow(5) = sCIR(idx).FAMOUNT rs\_DataRow(6) = sCIR(idx).FMARGIN\_PERCENT rs\_DataRow(7) = sCIR(idx).FMARGIN\_PROFIT 'Add up the total cost value m\_totalCost += sCIR(idx).FCOST \* sCIR(idx).FSHIPQTY 'Add up the total price value m\_totalPrice += sCIR(idx).FPRICE \* sCIR(idx).FSHIPQTY 'Calculate the average margin of all the items 'm\_avgMarkup += 'Add up the total margin value m\_totalMargin += sCIR(idx).FMARGIN\_PROFIT rs\_Table.Rows.Add(rs\_DataRow) Next End If
It just sounds like you need the information about how many items are sold and at what price; then the math is pretty straight forward. (The sum of all (Item*Price))/Total numbers of items PS. You are not looking for the weighted sum, unless you don't know how many items are sold. But then your math can't be done.
-
I sort of need to calculate the average of all the averages in a report. I have no clue how to do this, but I do have data. Do I have enough data here to do this, and perhaps some help with the formula I saw a couple of examples, but wow it looked so complex. http://study.com/academy/lesson/calculating-weighted-average-method-formula-example.html[^]
If (sCIR.Length > 0) Then
For idx As Integer = 0 To sCIR.Length - 1rs\_DataRow = rs\_Table.NewRow() rs\_DataRow(0) = sCIR(idx).FITEMNO rs\_DataRow(1) = sCIR(idx).FDESCRIPT rs\_DataRow(2) = sCIR(idx).FSHIPQTY rs\_DataRow(3) = sCIR(idx).FCOST rs\_DataRow(4) = sCIR(idx).FPRICE rs\_DataRow(5) = sCIR(idx).FAMOUNT rs\_DataRow(6) = sCIR(idx).FMARGIN\_PERCENT rs\_DataRow(7) = sCIR(idx).FMARGIN\_PROFIT 'Add up the total cost value m\_totalCost += sCIR(idx).FCOST \* sCIR(idx).FSHIPQTY 'Add up the total price value m\_totalPrice += sCIR(idx).FPRICE \* sCIR(idx).FSHIPQTY 'Calculate the average margin of all the items 'm\_avgMarkup += 'Add up the total margin value m\_totalMargin += sCIR(idx).FMARGIN\_PROFIT rs\_Table.Rows.Add(rs\_DataRow) Next End If
Hi, you can get the average by doing this: m_avgMarkup += sCIR(idx).FMARGIN_PERCENT /idx below is the whole code,
If (sCIR.Length > 0) Then
For idx As Integer = 0 To sCIR.Length - 1rs\_DataRow = rs\_Table.NewRow() rs\_DataRow(0) = sCIR(idx).FITEMNO rs\_DataRow(1) = sCIR(idx).FDESCRIPT rs\_DataRow(2) = sCIR(idx).FSHIPQTY rs\_DataRow(3) = sCIR(idx).FCOST rs\_DataRow(4) = sCIR(idx).FPRICE rs\_DataRow(5) = sCIR(idx).FAMOUNT rs\_DataRow(6) = sCIR(idx).FMARGIN\_PERCENT rs\_DataRow(7) = sCIR(idx).FMARGIN\_PROFIT 'Add up the total cost value m\_totalCost += sCIR(idx).FCOST \* sCIR(idx).FSHIPQTY 'Add up the total price value m\_totalPrice += sCIR(idx).FPRICE \* sCIR(idx).FSHIPQTY 'Calculate the average margin of all the items 'm\_avgMarkup += sCIR(idx).FMARGIN\_PERCENT /idx 'Add up the total margin value m\_totalMargin += sCIR(idx).FMARGIN\_PROFIT rs\_Table.Rows.Add(rs\_DataRow) Next End If
hi
-
Hi, you can get the average by doing this: m_avgMarkup += sCIR(idx).FMARGIN_PERCENT /idx below is the whole code,
If (sCIR.Length > 0) Then
For idx As Integer = 0 To sCIR.Length - 1rs\_DataRow = rs\_Table.NewRow() rs\_DataRow(0) = sCIR(idx).FITEMNO rs\_DataRow(1) = sCIR(idx).FDESCRIPT rs\_DataRow(2) = sCIR(idx).FSHIPQTY rs\_DataRow(3) = sCIR(idx).FCOST rs\_DataRow(4) = sCIR(idx).FPRICE rs\_DataRow(5) = sCIR(idx).FAMOUNT rs\_DataRow(6) = sCIR(idx).FMARGIN\_PERCENT rs\_DataRow(7) = sCIR(idx).FMARGIN\_PROFIT 'Add up the total cost value m\_totalCost += sCIR(idx).FCOST \* sCIR(idx).FSHIPQTY 'Add up the total price value m\_totalPrice += sCIR(idx).FPRICE \* sCIR(idx).FSHIPQTY 'Calculate the average margin of all the items 'm\_avgMarkup += sCIR(idx).FMARGIN\_PERCENT /idx 'Add up the total margin value m\_totalMargin += sCIR(idx).FMARGIN\_PROFIT rs\_Table.Rows.Add(rs\_DataRow) Next End If
hi
That's a point in the right direction. I'll try something similar to that.
If (sCIR.Length > 0) Then
Dim idx As Integer = 0
For idx = 0 To sCIR.Length - 1rs\_DataRow = rs\_Table.NewRow() rs\_DataRow(0) = sCIR(idx).FITEMNO rs\_DataRow(1) = sCIR(idx).FDESCRIPT rs\_DataRow(2) = sCIR(idx).FSHIPQTY rs\_DataRow(3) = sCIR(idx).FCOST rs\_DataRow(4) = sCIR(idx).FPRICE rs\_DataRow(5) = sCIR(idx).FAMOUNT rs\_DataRow(6) = sCIR(idx).FMARGIN\_PERCENT rs\_DataRow(7) = sCIR(idx).FMARGIN\_PROFIT 'Add up the total cost value m\_totalCost += sCIR(idx).FCOST \* sCIR(idx).FSHIPQTY 'Add up the total price value m\_totalPrice += sCIR(idx).FPRICE \* sCIR(idx).FSHIPQTY 'Calculate the average margin of all the items m\_avgMarkup += sCIR(idx).FMARGIN\_PERCENT 'Add up the total margin value m\_totalMargin += sCIR(idx).FMARGIN\_PROFIT rs\_Table.Rows.Add(rs\_DataRow) Next m\_avgMarkup = m\_avgMarkup / idx End If