I have a cross table as follows -
ColumnA ColumnB ColumnC
+================+===========+===========+===========+===========+===========+===========+
| Store Location | Category1 | Category2 | Category1 | Category2 | Category1 | Category2 |
+================+===========+===========+===========+===========+===========+===========+
| Boston | 200 | 100 | 250 | 230 | 230 | 210 |
+----------------+-----------+-----------+-----------+-----------+-----------+-----------+
| New York | 180 | 150 | 310 | 270 | 240 | 220 |
+----------------+-----------+-----------+-----------+-----------+-----------+-----------+
| Stockholm | 190 | 140 | 180 | 160 | 220 | 210 |
+----------------+-----------+-----------+-----------+-----------+-----------+-----------+
| London | 170 | 140 | 340 | 310 | 420 | 380 |
+----------------+-----------+-----------+-----------+-----------+-----------+-----------+
I want to calculate the difference between two categories for each Columns as follows -
ColumnA ColumnA Diff ColumnB ColumnB Diff ColumnC ColumnC Diff
+================+===========+===========+=====+===========+===========+====+===========+===========+====+
| Store Location | Category1 | Category2 | | Category1 | Category2 | | Category1 | Category2 | |
+================+===========+===========+=====+===========+===========+====+===========+===========+====+
| Boston | 200 | 100 | 100 | 250 | 230 | 20 | 230 | 210 | 20 |
+----------------+-----------+-----------+-----+-----------+-----------+----+-----------+-----------+----+
| New York | 180 | 150 | 30 | 310 | 270 | 40 | 240 | 220 | 20 |
+----------------+-----------+-----------+-----+-----------+-----------+----+-----------+-----------+----+
| Stockholm | 190 | 140 | 50 | 180 | 160 | 20 | 220 | 210 | 10 |
+----------------+-----------+-----------+-----+-----------+-----------+----+-----------+-----------+----+
| London | 170 | 140 | 30 | 340 | 310 | 30 | 420 | 380 | 40 |
+----------------+-----------+-----------+-----+-----------+-----------+----+-----------+-----------+----+
My horizontal axes expression is as follows -
[Axis.Default.Names] NEST [CategoryName]
What custom expression need to use to get it? Appreciate any suggestions.
Thanks a lot.
I haven't found a great way to do this in the cross table. There is one way but it's a little messy depending on how many different values are in the category column and you'd need to know the values in advance. Basically in the cell values axis you would write a custom expression for each column you'd like to see rendered on the horizontal axis. Something like this for each axis:
Vertical Axis:[Store Names]
Horizontal Axis: (Column Names) <--written just like that, or selected from the dropdown on the axis
Values Axis:
sum(if([category]="A", [sales])) as [Sum of A],
sum(if([category]="B", [sales])) as [Sum of B],
sum(if([category]="A", [sales])) - sum(if([category]="B", [sales]) as [delta A-B]
So long as you have "(column names)" on the one of the axes, you can write independent expressions separated by commas on the values axis to back your way into a blend of calculations that aren't applied uniformly to whatever else is on the axis. Its a bit of a slog and can cause issues when new values pop up in your data unexpectedly but it works. Unfortunately it doesn't play nice with marking though. Good luck.
Related
| A | B | C | D | E |
--|-------------|------------|-----------------|----------------------|-------------|-
1 | Product | sales_plan | sales_actuals | purchase_quantity | |
2 | Product_A | 500 | 400 | 1200 | Product_B |
3 | Product_B | 800 | 900 | 3000 | 5000 |
4 | Product_B | 300 | 490 | 2000 | |
5 | Product_D | 900 | 820 | 7000 | |
6 | Product_D | 200 | 250 | 5000 | |
7 | Product_D | 700 | 600 | 4000 | |
Wit reference to the answer in this question in Cell E3 I want to sum up the
purchase_quantity in Column D
a) if the sales_actuals > sales_plan and
b) if the product matches with the entry in Cell E2.
I tried to go with this formula but could not make it work:
=SUMPRODUCT((C2:C7>B2:B7)*D2:D7;A2:A7=E2)
How do I need to modify it to get the correct value?
As you can see in the comments the answer from JvdV is working:
=SUMPRODUCT((C2:C7>B2:B7)*(A2:A7=E2)*D2:D7)
| A | B | C | D | E |
--|-------------|------------|-----------------|----------------------|-------------|-
1 | Product | sales_plan | sales_actuals | purchase_quantity | |
2 | Product_A | 500 | 400 | 1200 | |
3 | Product_B | 800 | 900 | 3000 | 10000 |
4 | Product_C | 300 | 490 | 2000 | |
5 | Product_D | 900 | 820 | 7000 | |
6 | Product_E | 200 | 250 | 5000 | |
7 | Product_F | 700 | 600 | 4000 | |
In Cell E3 I want to sum up the purchase_quantity in Column D if the sales_actuals > sales_plan.
I know I could do this by inserting a helper column and then build the sum over this helper column.
However, I would prefer a solution without this helper column.
Something like this
=SUMPRODUCT(SUMIFS(C:C;C:C-B:B;"<0"))
Do you have any idea how to solve it?
As you can see in the comments the answer from JvdV is working:
=SUMPRODUCT((C2:C7>B2:B7)*D2:D7)
Excel-File
| A | B | C | D | E |
---|--------------|-------------------|--------|-----------------|------------|----
1 | Product | Sales | | Product | Sales |
---|--------------|-------------------|--------|-----------------|------------|----
2 | Product_A | 20 | | Product_D | 100 |
3 | Product_A | 10 | | Product_D | 90 |
4 | Product_A | 50 | | Product_B | 80 |
5 | Product_B | 80 | | Product_A | 50 |
6 | Product_C | 40 | | Product_D | 50 |
7 | Product_C | 30 | | Product_D | 50 |
8 | Product_D | 100 | | Product_C | 40 |
9 | Product_D | 90 | | Product_C | 30 |
10 | Product_D | 50 | | Product_A | 20 |
11 | Product_D | 50 | | Product_D | 10 |
12 | | | | | |
In Column A I have list of different products with their corresponding sales in Column B.
Products can appear mutliple times in the list.
Sales numbers can be equal for multiple products.
Now, I want to create a descending list of the products in Column D and Column E depending on the sales in Column B.
I tried to go with =LARGE(B3:B12,1), =LARGE(B3:B12,2), ... but it delets all duplicates from the list.
Do you have any idea what formular I need to make this list work?
Here is a solution that should work in older versions.
I create a Table and am using structured references, for flexibility, but you can convert to regular addressing if you need to:
D2: =INDEX(Table31[Product],AGGREGATE(15,6,1/(Table31[Sales]=E2)*ROW(Table31[Sales]),COUNTIF($E$2:E2,E2))-ROW(Table31[#Headers]))
E2: =LARGE(Table31[Sales],ROWS($A$1:A1))
Selectd D2:E2 and fill down as far as needed
Office 356 Solution:
=SORT(A2:B11,2,-1,FALSE)
Including Filters:
=SORT(FILTER(A2:B11,A2:A11=M2,""),2,-1,FALSE)
Including multiple Filters-Criterias:
=SORT(FILTER(A2:B11,(A2:A11=M2)*(A2:A11=M2)*(A2:A11=M2),""),2,-1,FALSE)
I'm not very experienced with excel, I have made 2 tables, one for our costs and one for our ticket sales.
I would like to make a chart visualizing how many tickets we need to sell to break even.
We don't have any variable costs so just want one horizontal line for the fixed costs (bottom of the left table) and one for ticket sales.
The problem I've got is we have 3 tiers of tickets at different prices so this wont just be a straight line. Each tier of ticket can only be bought once the previous tier has run out. I.e after 50 tickets have been sold, the price goes up to £7.
Here are the tables:
EDIT:
This is the kind of chart I want to make:
Set up another table that has the # of sales as one line item, and the cost as a second line item, and build the chart (under the insert menu) from it.
The data should look similar (but with the full numbers) to the attached picture.
It should end up looking similar (but smoother) to this:
One way to get to where you want to go is set up the following data table:
| Qty | Tier1 | Tier2 | Tier3 | BE |
|-----|-------|-------|-------|------|
| 10 | 50 | 50 | 50 | 1015 |
| 20 | 100 | 100 | 100 | 1015 |
| 30 | 150 | 150 | 150 | 1015 |
| 40 | 200 | 200 | 200 | 1015 |
| 50 | 250 | 250 | 250 | 1015 |
| 60 | | 320 | 320 | 1015 |
| 70 | | 390 | 390 | 1015 |
| 80 | | 460 | 460 | 1015 |
| 90 | | 530 | 530 | 1015 |
| 100 | | 600 | 600 | 1015 |
| 110 | | 670 | 670 | 1015 |
| 120 | | 740 | 740 | 1015 |
| 130 | | 810 | 810 | 1015 |
| 140 | | 880 | 880 | 1015 |
| 150 | | 950 | 950 | 1015 |
| 160 | | | 1040 | 1015 |
| 170 | | | 1130 | 1015 |
| 180 | | | 1220 | 1015 |
| 190 | | | 1310 | 1015 |
| 200 | | | 1400 | 1015 |
| 210 | | | 1490 | 1015 |
| 220 | | | 1580 | 1015 |
| 230 | | | 1670 | 1015 |
| 240 | | | 1760 | 1015 |
| 250 | | | 1850 | 1015 |
which list out the quantities and corresponding revenue under each tier plus the break even target which would be the fixed cost in your example.
Highlight the data table and insert a Line Chart from it. The line chart will look funny in the first place.
Click anywhere within the line chart, you will see a Design tab showing on your ribbon, go to that tab and click on the Select Data button:
Then manually modify the Series (left section) and Axis Labels (right section) as shown below:
Where Tier1 should be all the data from the Tier1 column, Tier2 should be all the data from the Tier2 column, Tier3 should be all the data from the Tier3 column, BE should be all the data from the BE column, and Axis Labels should be all the data from the Qty column.
If you have set up the data correctly (and ordered the series in the exact way as mine) , then you should have something similar to the following:
Please note I have modified the formats and styling of the chart to make it look more "attractive". The water is quite deep in the world of charting in Excel and I will leave it to you to explore.
A tip here, you can click on any elements of the chart, and press Ctrl+1 key on your key board to bring out the format panel on the right of your worksheet. You can test out each function and eventually craft the chart in a way you desired. Or you can use a standard style given in the Design tab.
Let me know if you have any questions. Cheers :)
Hi I am currently working on a project that contains individual information for each month and I want to build a table or two to contain the information(I don't want to create a table for each month). a simple illustration will be :
Jan
weight height
student a
student b
Feb
weight height
student a
student b
student c
what I what is just to export data to excel in the form of the above, weight, height column are fixed but I want to have data clustered by month so that the data organization is clearer.
May I ask how to design the database so that the abovementioned requirement could be met? Thanks.
Here are the tables you'll need to store the information:
students
id unsigned int(P)
name varchar(50)
+----+------+
| id | name |
+----+------+
| 1 | John |
| 2 | Mary |
| 3 | Tina |
| .. | .... |
+----+------+
In the measurements table the Primary Key is formed by the student_id, year and month. The student_id is also a foreign key to the students table.
measurements
student_id unsigned int(F students.id)-\
year unsigned int ----------------(P)
month unsigned int ---------------/
height unsigned int
weight unsigned int
+------------+------+-------+--------+--------+
| student_id | year | month | height | weight |
+------------+------+-------+--------+--------+
| 1 | 2013 | 11 | 70 | 200 |
| 2 | 2013 | 11 | 65 | 130 |
| 1 | 2013 | 12 | 70 | 192 |
| 2 | 2013 | 12 | 65 | 126 |
| 3 | 2013 | 12 | 68 | 140 |
| .......... | .... | ..... | ...... | ...... |
+------------+------+-------+--------+--------+
And then a query to extract the information:
SELECT name, height, weight, year, month
FROM students s
LEFT JOIN measurements m ON s.id = m.student_id
ORDER BY year, month, name
Which will give you:
+------+--------+--------+------+-------+
| name | height | weight | year | month |
+------+--------+--------+------+-------+
| John | 70 | 200 | 2013 | 11 |
| Mary | 65 | 130 | 2013 | 11 |
| John | 70 | 192 | 2013 | 12 |
| Mary | 65 | 126 | 2013 | 12 |
| Tina | 68 | 140 | 2013 | 12 |
+------+--------+--------+------+-------+
Which is the data you want, sorted in the way you want. Any further formatting of the data is up to your application.