I've came across this task and I'm stuck big time. I've tried a PivotTable but it didn't give me the desired result. The only thing that works is a manual transpose but the number of records is 5k odd.
What I'm trying to achieve here is to transpose the data from rows for the company into columns so at a later stage to be able to count the number of votes and average per company.
PivotTable can do the job. All you need is a helper column using COUNTIFS. Notice the formula in cell D2.
And the PivotTable would look like this (set to Tabular Layout)
A note to take here is COUNTIFS can get really slow when the number of records grow to around 10k or more (or just my slow pc :/). When this happens, the workaround is: first sort your data, then use COUNTIFS over a limited number of cells only. For example, at cell D2, the formula will be =COUNTIFS(A2:A102,A2,B2:B102,B2), hence counting only 100 records rather than the whole bunch as you fill down the formula.
If what you want is the number of votes and average per company, that can be done in a variety of ways.
Using a Pivot Table, drag companies to the rows area; drag rating to the values area twice. Then change the Value Field setting on one of the Ratings to Count; and on the other to Average.
Add some formatting and various options gives you:
Or if you have a list of the Organizations (Company Names) in, let us say, G3:Gn, and your data table in columns A:C, you can use formulas:
Count: H3: =COUNTIF($B$1:$B$1000,G3)
Average: I3: =AVERAGEIF($B$1:$B$1000,G3,C1:$C$1000)
And fill down as far as needed.
Since you mentioned a PT did not suit , assuming RATING is in F2, please try in G3 copied down to suit:
=IF(AND(COLUMN()-7<COUNTIF($E:$E,$E3),$E2<>$E3),OFFSET($F3,COLUMN()-7,0),"")
then drag all the formulae to the right until an entire column appears blank. Note this requires the TARGET ATTENDEE ORGANIZATION column be sorted.
Related
Example of Product Data and Inbounds
I have 20 products that I sell that each have some requested amount that people want to buy. I am struggling to figure out a formula by which I could have it return the week where the sum of it and previous weeks is greater than the amount requested, so I know on what week of inbounds the order can be fulfilled.
The example data only shows three columns of dates but in reality there could be up to 20 weeks of inbounds inventory, so it would be potentially a large series of sums before it finds the one greater than the amount requested. In the example image the cells highlighted in green are the correct week for each product that I manually marked.
Thanks for the help, I'm not sure where to even start on this.
Assuming that your table start in cell A1 (therefore the cell C2 value is 96), use this formula for your conditional formatting starting from cell C2:
=AND(SUM($C2:C2)>=$B2,SUM($B2:B2)-$B2<$B2)
Warning: the formula might stop working if the overall structure of the table is changed. For example: if columns with non-numeric data are inserted, the user will need to re-apply the conditional formatting. If said inserted columns will contain numeric value that are not meant to be sum in the formula, it won't suffice anymore.
I am afraid I don't have time to write a full answer but the below might help. I am sure there is a way to avoid writing multiple COUNTIFS with a SUMPRODUCT but I haven't got there yet.
=SUM(1,
COUNTIFS($B3,">"&$C3),
COUNTIFS($B3,">" & SUM($C3:$D3)),
COUNTIFS($B3,">" & SUM($C3:$E3))
)
This is a model built around your having 20 weeks so that you can have one formula which doesn't require continuous adjustment - it does require one column of helper cells for each week, though:
the helper cells start in column Y, where the formula in Y2 is
=SUM($C2:C2)
which is then copied to the right as far as column AR, and then copied down, one row for each of your products.
With all of the helper cells populated, the array formula in W2 is
=IFNA(INDEX($C$1:$V$1,MATCH(1,N((Y2:AR2-B2)>0),0)),"In the future")
which is then copied down, one row for each of your products.
I have two tables that look like these:
Each order ID can appear many times without limit. The total sales amount in col E is the total amount of all sales with that Order ID in OrderDetail Table, so in this case total sales amount for order 122 should be 97.
However, if there is ANY occurrence of "Cancel" in col J, regardless of how many times the order is made, ALL sales amount for that order ID is cancelled. So for this example, the total sales amount for Order 120 and 121 should be zero, and "Cancel" status should be recorded for both Order ID in Col D.
I tried these formulas for D4 and E4, dragging them down to the end of the table. But as you can see, the formulas clearly don't work.
D4: =INDEX($J$4:$J$11,MATCH(B4,$G$4:$G$11,0))
E4: =SUMIFS($H$4:$H$11,$G$4:$G$11,B$4,$J$4:$J$11,$J$4:$J$11<>"Cancel")
The formula can't be array formula, because both tables will keep expanding as new orders coming in.
Anybody can help me with this problem? Maybe I am missing something out, but I just can't seem to figure this out. Any help would be appreciated.
You have a couple of issues with your ranges not matching in your formulas which could be solved by using full column references instead of just ranges. (As I'm sure Jeeped was about to suggest in the comments)
INDEX(MATCH()) is returning only the first match in your formula in D4, you will do better with using a conditional COUNTIFS() instead:
=IF(COUNTIFS(J:J,"Cancel",G:G,B4)>0,"Cancel","")
There's some typos in your second formula that would be easier rectified if you use full column references, this should do the trick:
=SUMIFS(H:H,G:G,B4,J:J,"<>Cancel")
If you have a basic table of values with participants sharing each itemized expense. The cells of the table represent their share of the amount, how do you sum all the per-item totals in one row at the bottom of the table?
I've tried using SUM(ARRAYFORMULA(B2:B5*C2:C5)), which gets close, but I need the divisor to be divided by the count all involved columns. Every time I try mapping the amount over the count of each row, it attempts to count all rows and columns together.
I have a working example on Google Sheets
Use SUMPRODUCT:
=SUMPRODUCT($B$2:$B$5*IFERROR(C2:C5/($C$2:$C$5+$D$2:$D$5+$E$2:$E$5),0))
You can also do it by developing the row totals of the 2d range C2:E5 and calculating the share for each person from there
=SUM($B$2:$B$5*N(+C$2:C$5)/(MMULT(N(+$C$2:$E$5),TRANSPOSE(COLUMN($C$2:$E$5)^0))))
It is an array formula and must be entered with CtrlShiftEnter or in Google Sheets as
=arrayformula(SUM($B$2:$B$5*N(+C$2:C$5)/(MMULT(N(+$C$2:$E$5),TRANSPOSE(COLUMN($C$2:$E$5)^0)))))
Another way of doing it in Excel is using OFFSET and SUBTOTAL, but it doesn't work in Google Sheets
=SUM($B$2:$B$5*N(+C$2:C$5)/SUBTOTAL(9,OFFSET($C$2,ROW(C$2:C$5)-ROW($C$2),0,1,COLUMNS($C$2:$E$5))))
I have a spreadsheet of statistics from sports games over a season, for different leagues - each row holds a single event that happened in a game, such as a penalty. There are many rows of events for each individual game. One of the columns is the league, another is the home team and another is the away team. How can I count the total number of games in a given league? In other words, I would need to count the number of unique pairs of strings from Home and Away, where League = "Ligue 1".
EDIT
I have tried:
=SUMPRODUCT(1/(COUNTIFS(E2:E81078,"Ligue 1",F2:F81078,F2:F81078,G2:G81078,G2:G81078)))
which returns a DIV/0 error (it does work if I dont include the column E = "Ligue 1" criteria).
This is similar to your formula but deals with the division by zero
=SUM(IFERROR((1/COUNTIFS(E2:E81078,"Ligue 1",F2:F81078,F2:F81078,G2:G81078,G2:G81078)),0))
Enter it with Ctrl+Shift+Enter rather than just Enter. If done correctly you will see {} around the formula
Try not to use ranges that are bigger than your data because it will slow these kind of formulas down significantly
Update
This might also work if your data is ordered the way you show in your question. It counts the number of times the home team changes in Ligue 1 data :
=SUMPRODUCT((F3:F81079<>F2:F81078)*(E2:E81078="Ligue 1"))
Note that the ranges in column F are offset by one row
You can do this with a Pivot Table.
Add a "helper" column where you concatenate the two teams, preferably with a delimiter in between, eg:
=CONCATENATE(B2, "|", C2)
Use, for example Teams for the column header
Then, Insert ► Pivot Table and be sure to select to Add to Data Model
This adds the option for Distinct Counts to the Values Settings
Then Drag "league" to the Rows area, "Teams" to the Values area, and select Distinct Count for the Value Setting
You might get a table similar to below, which you can format in many different ways:
EXCEL SCREENSHOT=SUMPRODUCT(1/COUNTIFS($B$1:$B$7,B1:B7,$C$1:$C$7,C1:C7))
TRY THIS =SUMPRODUCT(1/COUNTIFS($B$1:$B$7,B1:B7,$C$1:$C$7,C1:C7))
I have an employee data base that contains names and 8 movement types (Ex. Recruitment, Resignation....etc). Also I have starting head counts.
What I need to do is calculating movement counts and head counts based on the month for 12 months. Currently i am using SUMIF formula to calculate all these and the thing is excel will be very slow with all formulas. Appreciate if anyone can help me on this. See the image below for sample of the formula and I need to insert this formula in more than 600 lines.
A pivot table would be a good way to go, but by the look of your criteria you'll need to create 'helper columns' to ensure your data is ready for aggregation in a Pivot table.
For instance in your master data tab, add a new column called 'MatchesCriteria' or words to that effect, and build a formula in that column that checks for all of the criteria that you want to have the report based on, and returns a 1 or a 0, e.g.
=IF( (IF(C2="Recruitment",1,0)+IF(D2="Secondment In",1,0)) > 0 , 1 , 0)
Then run a pivot table including the 'Plant' column in your Rows, the month column in your columns and the 'MatchesCriteria' in your data values, and switch the calculation type to 'SUM' rather than 'COUNT'.
This will do the trick and will refresh in a flash compared to evaluating all of those countif statements.