Change format of Excel - excel

So I'd like to essentially transpose the format of an Excel file. The original format is below:
**2015-03-08 2015-03-08 2015-03-15 2015-03-15**
**brand_code All New bookings Average Lead Time All New bookings Average lead time**
Brand A 2 7.84 4 4.54
Brand B 6 9.63 9 2.34
I'd like to convert this format to the one shown below:
Category 2015-03-08 2015-03-15
All new bookings(Brand A) 2 4
All new bookings(Brand B) 6 9
Average Lead Time(Brand A) 7.84 4.54
Average Lead Time(Brand B) 9.63 2.34
I'd like to do this in Excel itself preferably. I do not want to write any R or other code for this. Some easy-to-use freeware would be acceptable.

First unpivot (there is a step-by-step guide and other references here) then add a column on the left and move/copy or fill it with All New bookings / Average Lead Time repeating to suit and label that Category. Concatenate the first to two columns into a third if desired. Now create a new PivotTable with layout to suit.

Related

Complex Multi-Conditional IF Function, return value

I need some help returning a desired figure with a complex formula. I've included a sample table with some dummy data, and have almost reached the solution which returns the correct true/false conditions but need some help printing the figure. My brain is a bit frazzled after working on this for a while...
PROBLEM:
I need to print the figure (6000/3000/0) based on not only calculation rule, but also return 0 if the calculated was already printed at the first instance.
RULES
Method Saving (Column E) is calculated using the methodology:
For each university with the same Product (col B), and same Agreement Year (col C), where Total (col D) returns: (6,000 if over 12,500 / 3,000 if under 12,500 / 0 if total = 0)
That is quite easy to achieve ^ -- however, the tricky part comes in when trying to only print the method saving figure once for each entry of the same university, same product and same agreement year.
Looking at the example table below, rows 2 & 3 both have the same university, product and agreement year. It's quite easy to produce a formula with multiple IF statements to print the calculation of either 6000/3000/0, however I only want to print the method saving figure once, at the first instance, following that the method saving figure should be 0.
Worth noting that in Row # 4, 6000 will be printed because even though University and Product are the same, the Agreement Year is different.
Row 1
University (col A)
Product (col B)
Agreement Year (col C)
Total (col D)
Method Saving (col E)
2
Manchester University
Photoshop
2022-2023
20,000
6,000
3
Manchester University
Photoshop
2022-2023
20,000
0
4
Manchester University
Photoshop
2021-2022
14,000
6,000
5
Manchester University
Photoshop
2021-2022
14,000
0
6
Oxford University
Illustrator
2022-2023
8,000
3,000
7
Cambridge University
Figma
2022-2023
0
0
8
Cambridge University
Linux
2022-2023
13,000
6,000
9
Bristol University
Linux
2022-2023
0
0
10
Coventry University
Lightroom
2021-2022
20,000
6,000
11
Coventry University
Lightroom
2022-2023
10,000
3,000
12
Coventry University
Lightroom
2022-2023
10,000
0
13
Coventry University
Photoshop
2022-2023
4,000
3,000
I have already worked on a potential solution, which may not be the most efficient, but for times sake it has gotten me the furthest. I've edited the cell references to match the dummy data table.
=IF(OR(AND(E1<>"",B2<>B1,C2<>C1),AND(E1<>"",D2=D1,C2<>C1)),
OR(AND(A2=A1,B2=B1,D2<12500,D2<>0),3000,
OR(AND(A2<>A1,B2<>B1,D2<12500,D2<>0),3000,
OR(AND(A2=A1,B2<>B1,D2<12500,D2<>0),3000,
OR(AND(A2<>A1,B2=B1,D2<12500,D2<>0),3000,
OR(AND(A2=A1,B2=B1,D2>12500,D2<>0),6000,
OR(AND(A2<>A1,B2<>B1,D2>12500,D2<>0),6000,
OR(AND(A2=A1,B2<>B1,D2>12500,D2<>0),6000,
OR(AND(A2<>A1,B2=B1,D2>12500,D2<>0),6000,
OR(D2=0,0,0))))))))),0)
The above formula when entered will correctly return TRUE or 0 based on the criteria above, so it has managed to figure out the logic behind it -- I'm just now having trouble at the very end to print the respective figure (6000/3000/ or importantly 0 if either Total is 0 or the figure has already been printed)
Let me know if you have any ideas / need me to clarify anything!
Thanks!
Try this in E2 and fill down:
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2,$C$2:C2,C2)=1,VLOOKUP(Sheet3!$D2,{0,0;1,3000;12500,6000},2),0)
I used a lookup table to determine what to return, and a COUNTIF to only return a non-zero if the entry is the first that matches those first three columns.

EXCEL formula to sum demand per date when multiple entries of dates exist

How do I sum the amount of demand I have for each date, when there are multiple entries for each date., e.g.
Sheet 1:
A B
Date Demand
13/7/21 5
13/7/21 4
13/7/21 2
15/7/21 6
15/7/21 3
16/7/21 2
16/7/21 4
So I'm trying to get a summary as follows:
Sheet 2:
A B
13/7/21 11
14/7/21 0
15/7/21 9
16/7/21 6
17/7/21 0
I've tried =SUMPRODUCT(--('Sheet 1'!$A$2:$A$240='Sheet 2'!A2),'Sheet 1'!$B$1:$B$240)
I'm not wanting to do a pivot table, as the pivot table does not give me the zero values for dates where there is no data (unless there is a way to show this in a pivot)
You can use SUMIFS() like
=SUMIFS(Sheet1!B:B,Sheet1!A:A,A1)
You can also use SUMPRODUCT() in this way.
=SUMPRODUCT((Sheet1!$B$2:$B$8)*(Sheet1!$A$2:$A$8=A1))
Put together quickly to start you off:
Edit to give text version of the solution to the OP's problem:
=SUMIFS(B6:B12,A6:A12,"="&G12)
Then you can do between by setting lower and upper criteria in the sumifs().

How do I specifiy the last row of a list in a range as it grows?

I have a list of items sold which grows longer with each sale. On a summary page I want to sum particular rows of a column.
Example:
Sheet1
Person Item Amount
1 5 6.00 This page has the knows the last column
1 7 10.50 by =counta($a2:$a20)+1 in cell f6
2 5 6.00
3 2 20.00
3 9 16.00
3 5 6.00
4 1 2.50
Summary Page:
Person Sales
1 =sumif(sales!$A$2:$A$8,$a2,sales!$C$1:$C$8) = 16.50
2 =sumif(sales!$A$2:$A$8,$a3,sales!$C$1:$C$8) = 6.00
3 =sumif(sales!$A$2:$A$8,$a4,sales!$C$1:$C$8) = 42.00
4 =sumif(sales!$A$2:$A$8,$a5,sales!$C$1:$C$8) = 2.50
On one page I create an indirect reference by =concatenate("sales!$c$2:$c$",sales!$a$10) but that won't work on this one page. Is there another way?
Please try:
=SUMIF(sales!A:A,A2,sales!C:C)
copied down to suit.
I would use dynamic named ranges:
=SUMIF(Sales!People,A2,Sales!Amounts)
Here is an article on how to create dynamic named ranges:
http://www.excel-easy.com/examples/dynamic-named-range.html
If this is really a "Table", in other words, you used the Insert Table method from the Insert Ribbon to set it up, then you can merely used structured references which will automatically expand as you add rows.
An equivalent of your formula, using structured references, and assuming you have renamed your table SalesTbl, might look like:
=SUMIF(SalesTbl[Person],$A2,SalesTbl[Amount])

Spreadsheet aggregation/manipulation

I have a spreadsheet structured like
2005 Alameda total HS graduates 1234
2005 Alameda UC enrollees 112
2006 Alameda total HS graduates 892
2006 Alameda UC enrollees 84
...
2009 Yolo total HS graduates 1300
2009 Yolo UC enrollees 93
and so on for every CA county for several years.
I want to generate a spreadsheet like this:
county 2005 2006 ...
Alameda 11.1% 9%
Alpine 7% 8%
...
Yolo 5.5% 4%
i.e. I want to project the years from rows to columns and have a row for each county, then divide the number of graduates (the data from each odd-numbered row in the original sheet) by the number of UC enrollees (even-row data) for each year, and insert it in the appropriate cell.
This would be easy enough for me to do in Java, but I want to get a feel for what's possible just using excel/Google sheets alone - how might I go about accomplishing this?
Assuming the counties are sorted, and they start in cell B2, enter =B2 in cell F2, and enter the following in F3:
=INDIRECT("B"&COUNTIF(B3:B$9999,"<="&F2)+ROW())
You can change 9999 based on the number of records, but it's fine as-is.
Copy F3 down as many rows as are needed:
You can then calculate percentages using SUMPRODUCT:
=IFERROR(
SUMPRODUCT(($A$2:$A$100=G$1)*
($B$2:$B$100=$F2)*
($C$2:$C$100="UC enrollees")*
$D$2:$D$100
)
/
SUMPRODUCT(($A$2:$A$100=G$1)*
($B$2:$B$100=$F2)*
($C$2:$C$100="total HS graduates")*
$D$2:$D$100
),
"")
The first SUMPRODUCT totals UC enrollees that match the year and county. The second SUMPRODUCT does the same for HS graduates. The results are divided, and IFERROR handles divide-by-zero errors for missing data.
Since your example shows percentages, I assume you want to divide UC enrollees by HS graduates, and not the other way around. Either way, I don't get the same totals as you, so let me know if I misunderstood.
Here is the pivot table way of doing it for comparison.
They are many ways of doing this but I've added column headers and chosen to use this formula to put percentages in even rows of column E and zeroes in odd rows in sheet 1:-
=IF(ISEVEN(ROW()),D3/D2*100,0)
Then I've inserted a pivot table in sheet 2 referring to my data in sheet 1 and set up the fields as shown and it's pretty automatic:-

Find the top n values in a range while keeping the sum of values in another range under x value

I'd like to accomplish the following task. There are three columns of data. Column A represents price, where the sum needs to be kept under $100,000. Column B represents a value. Column C represents a name tied to columns A & B.
Out of >100 rows of data, I need to find the highest 8 values in column B while keeping the sum of the prices in column A under $100,000. And then return the 8 names from column C.
Can this be accomplished?
EDIT:
I attempted the Solver solution w/ no luck. 200 rows looks to be the max w/ Solver, and that is what I'm using now. Here are the steps I've taken:
Create a column called rank RANK(B2,$B$2:$B$200) (used column D -- what is the purpose of this?)
Create a column called flag just put in zeroes (used column E)
Create 3 total cells total_price (=SUM(A2:A200)), total_value (=SUM(B2:B200)) and total_flag (=(E2:E200))
Use solver to minimize total_value (shouldn't this be maximize??)
Add constraints -Total_price<=100000 -Total_flag=8 -Flag cells are binary
Using Simplex LP, it simply changes the flags for the first 8 values. However, the total price for the first 8 values is >$100,000 ($140k). I've tried changing some options in the Solver Parameters as well as using different solving methods to no avail. I'd like to post an image of the parameter settings, but don't have enough "reputation".
EDIT #2:
The first 5 rows looks like this, price goes down to ~$6k at the bottom of the table.
Price Value Name Rank Flag
$22,538 42.81905675 Blow, Joe 1 0
$22,427 37.36240932 Doe, Jane 2 0
$17,158 34.12127693 Hall, Cliff 3 0
$16,625 33.97654031 Povich, John 4 0
$15,631 33.58212402 Cow, Holy 5 0
I'll give you the solver solution as a starting point. It involves the creation of some extra columns and total cells. Note solver is limited in the amount of cells it can handle but will work with 100 anyway.
Create a column called rank RANK(B2,$B$2:$B$100)
Create a column called flag just put in zeroes
Create 3 total cells total_price, total_value and total_flag
Use solver to minimize total_value
Add constraints
-Total_price<=100000
-Total_flag=8
-Flag cells are binary
This will flag the rows you want and you can grab the names however you want.

Resources