Excel pivot table - excel

I have a homework assingment. But i didn't get it exactly what i have to do.
"create a PivotTable with the smallest sales per agent and per article. there may be no grand totals shown. the field names must be in the PivotTable."
i did something like that. but it didn't seems like correct.
this is the table!
Row Labels Min of Sales
1-
1 12589
2 14700
2-
1 12300
2 12365
Date Artikel agent Channel Sales
3.01.2015 1 1 1 45612
3.01.2015 2 2 1 12365
4.01.2015 1 2 1 12345
4.01.2015 1 2 2 45230
5.01.2015 2 1 2 45610
6.01.2015 2 1 1 74102
6.01.2015 1 2 1 12300
7.01.2015 1 1 2 12589
7.01.2015 2 2 1 45600
9.01.2015 2 1 2 45600
9.01.2015 1 2 2 65400
10.01.2015 2 1 2 54600
10.01.2015 1 2 1 56400
13.01.2015 2 1 2 74100
13.01.2015 1 2 2 14700
14.01.2015 1 1 2 32500
14.01.2015 1 2 1 65200
18.01.2015 2 2 2 36900
18.01.2015 2 1 1 25800
22.01.2015 2 1 1 14700
22.01.2015 1 1 2 41700
23.01.2015 1 2 2 52800
23.01.2015 1 1 1 63900
26.01.2015 1 2 2 35700
26.01.2015 2 2 1 15900
27.01.2015 1 1 1 97100
28.01.2015 1 2 1 31700
31.01.2015 1 1 1 93100

If you Dont Want Grand Total, you can right Click on Row Labels and select Pivot Table Option and Select Totals & Filters And Uncheck the Show Grand Totals for Column.
Filed Names you can Manually Edit or You Can Choose Custom Name by Selecting Value Field Settings.

It sounds like you need to use the Agent and Artikel as the row labels, and remove the date.

Related

Row comparison on different tables

friends.
I'm trying to figure out a formula that verifies if there is a matching row from table 2 on table 1. If not, the formula must show that the row were not listed, like stated on column E (CHECK). Is that possible? Or maybe a VBA macro, idk.
TABLE 1
A
B
C
D
29
1
1
1
29
2
1
2
30
3
1
2
15
1
1
1
15
2
1
2
15
3
1
2
20
1
1
1
20
2
1
2
20
3
2
1
20
4
2
2
20
5
1
3
TABLE 2
A
B
C
D
CHECK
29
1
1
1
EXISTS
15
1
1
2
NOT
15
2
1
2
EXISTS
15
3
1
2
EXISTS
20
6
1
1
NOT
100
1
2
3
NOT LISTED
Thanks, guys, would appreciate some help.

Change every CSV file value

I'm sure there's a simple solution to this but I'm struggling. I want to set the values of a csv file I've created to 1s and 0s so that I can work out the probability based on each row.
Here's the csv data:
0 1 2 3 4 5 6 7 \
0 Reference China Greece Japan S Africa S Korea Sri lanka Taiwan
1 1 1 1 1 1 1 1 1
2 1 1 1 1 1 1 1 1
3 1 1 1 1 1 1 1 1
4 1 1 1 1 1 1 1 1
... ... ... ... ... ... ... ... ...
14898 1 1 1 1 1 1 1 1
14899 1 1 1 1 1 1 1 1
14900 1 1 1 1 1 1 1 1
14901 1 1 1 1 1 1 1 1
14902 1 1 1 1 1 1 1 1
8 9 10 11 12 13 14 15 16
0 USA Ecuador Egypt Ghana India Isreal Pakistan Taiwan USA Ohio
1 1.031 1 1 1 1 1 1 1 1
2 1.031 1 1 1 1 1 1 1 1
3 1.031 1 1 1 1 1 1 1 1
4 1.031 1 1 1 1 1 1 1 1
... ... ... ... ... ... ... ... ... ...
14898 1 1 1 1 1 1 1 1 1
14899 1 1 1 1 1 1 1 1 1
14900 1 1 1 1 1 1 1 1 1
14901 1 1 1 1 1 1 1 1 1
14902 1 1 1 1 1 1 1 1 1
[14903 rows x 17 columns]
And I've tried this:
data = pd.DataFrame(pd.read_csv('IEratios.csv', header=None, sep=','))
for x in data:
if x == 1:
x = 0
else:
x = 1
Which I thought would be simple and work but I was wrong and everywhere I look nothing I find seems to apply to all columns and rows, so I am lost.
You can use the .map() function in pandas, this allows you to run a function trough an entire DF column like so:
def changeNumber(x):
if x == 1:
return 0
else:
return 1
df = pd.read_csv('IEratios.csv', sep=',')
df['China'] = df['china'].map(changeNumber)
I don't know if I understand what you want to do.
Do you want to replace the values that are one by zero, and the zeros by one?
If I understand correctly, how are you using panda you can use the following statement
df.replace({"0": "1", "1": "0"}, inplace=True)
You have to be careful with the data type of your dataframe
Have you tried using the numpy.where function?
data = pd.DataFrame(pd.read_csv('IEratios.csv', header=None, sep=','))
data = np.where((data == 1), 0, 1)

Sum whenever another column changes

I have a df with VENDOR, INVOICE and AMOUNT. I want to create a column called ITEM, which starts at 1, and when the invoice number changes it will change to 2 and so on.
I tried using cumsum, but it isn't actually working - and it makes sense not to work. The way I wrote the code it will sum 1 for the same invoice and start over when the invoice changes.
data = pd.read_csv('data.csv')
data['ITEM_drop'] = 1
s = data['INVOICE'].ne(data['INVOICE'].shift()).cumsum()
data['ITEM'] = data.groupby(s)['ITEM_drop'].cumsum()
Output:
VENDOR INVOICE AMOUNT ITEM_drop ITEM
A 123 10 1 1
A 123 12 1 2
A 456 44 1 1
A 456 5 1 2
A 456 10 1 3
B 999 7 1 1
B 999 1 1 2
And what I want is:
VENDOR INVOICE AMOUNT ITEM_drop ITEM
A 123 10 1 1
A 123 12 1 1
A 456 44 1 2
A 456 5 1 2
A 456 10 1 2
B 999 7 1 3
B 999 1 1 3

sumproduct in different columns between dates

Im trying to sum between two dates across columns. If I had a start date input in Sheet1!F1 and an end date input in Sheet1!F2 and I needed to multiply column B times column E.
I can do sumproduct(Sheet1!B2:B14,Sheet1!E2:E14) which would result in 48 based on the example table below. However, I need to include date parameters so I could choose between dates 2/1/15 and 6/1/15 which should result in 20.
A B C D E
Date Value1 Value2 Value3 Value4
1/1/2015 1 2 3 4
2/1/2015 1 2 3 4
3/1/2015 1 2 3 4
4/1/2015 1 2 3 4
5/1/2015 1 2 3 4
6/1/2015 1 2 3 4
7/1/2015 1 2 3 4
8/1/2015 1 2 3 4
9/1/2015 1 2 3 4
10/1/2015 1 2 3 4
11/1/2015 1 2 3 4
12/1/2015 1 2 3 4
Try,
=SUMPRODUCT((Sheet1!A2:A14>=Sheet1!F1)*(Sheet1!A2:A14<=Sheet1!F2)*Sheet1!B2:B14*Sheet1!E2:E14)

Grouping and Subtotals for total sales per agent, per day

Hi I asked today a similar question but i forgot to ask this one.
what i have to do is.But i didn't find out how to do it exactly.
"Make a table showing the total sales per agent, per day (data on the x-axis). View the report in the outline view and set the subtotals below the group. Repeat the number of agents within each group."
this is the table.
Datum Artikel Agent Kanaal Sales
3.01.2015 1 1 1 45612
3.01.2015 2 2 1 12365
4.01.2015 1 2 1 12345
4.01.2015 1 2 2 45230
5.01.2015 2 1 2 45610
6.01.2015 2 1 1 74102
6.01.2015 1 2 1 12300
7.01.2015 1 1 2 12589
7.01.2015 2 2 1 45600
9.01.2015 2 1 2 45600
9.01.2015 1 2 2 65400
10.01.2015 2 1 2 54600
10.01.2015 1 2 1 56400
13.01.2015 2 1 2 74100
13.01.2015 1 2 2 14700
14.01.2015 1 1 2 32500
14.01.2015 1 2 1 65200
18.01.2015 2 2 2 36900
18.01.2015 2 1 1 25800
22.01.2015 2 1 1 14700
22.01.2015 1 1 2 41700
23.01.2015 1 2 2 52800
23.01.2015 1 1 1 63900
26.01.2015 1 2 2 35700
26.01.2015 2 2 1 15900
27.01.2015 1 1 1 97100
28.01.2015 1 2 1 31700
31.01.2015 1 1 1 93100
and this is what i've done.
Sum of Sales Column Labels
Row Labels 1 2 Grand Total
1
3.01.2015 45612 45612
5.01.2015 45610 45610
6.01.2015 74102 74102
7.01.2015 12589 12589
9.01.2015 45600 45600
10.01.2015 54600 54600
13.01.2015 74100 74100
14.01.2015 32500 32500
18.01.2015 25800 25800
22.01.2015 14700 41700 56400
23.01.2015 63900 63900
27.01.2015 97100 97100
31.01.2015 93100 93100
1 Total 414314 306699 721013
2
3.01.2015 12365 12365
4.01.2015 12345 45230 57575
6.01.2015 12300 12300
7.01.2015 45600 45600
9.01.2015 65400 65400
10.01.2015 56400 56400
13.01.2015 14700 14700
14.01.2015 65200 65200
18.01.2015 36900 36900
23.01.2015 52800 52800
26.01.2015 15900 35700 51600
28.01.2015 31700 31700
2 Total 251810 250730 502540
Grand Total 666124 557429 1223553
It is related to Grouping see the below links.
http://www.wikihow.com/Group-and-Outline-Excel-Data
http://office.microsoft.com/en-in/excel-help/..
Below is the Screen Shot for Better understanding. Now you try to get the required output.

Resources