Excel Pivot Chart - % Of Two Values - excel

Let's say I have the following table:
CORP | COAST | CITY | DONE | MISSING | TOTAL
-------------------------------------
New | West | LAX | 2 | 4 | 6
Old | West | SFO | 3 | 3 | 6
New | East | NYC | 4 | 2 | 6
I make a pivot table that looks like this:
CORP:
COAST: NEW | OLD
-------------------------------------
EAST |
SUM OF TOTAL | 6 |
SUM OF DONE | 4 |
SUM OF MISSING | 2 |
WEST
SUM OF TOTAL | 6 | 6
SUM OF DONE | 2 | 3
SUM OF MISSING | 4 | 3
I want to now add a ROW that is the percentage DONE of the TOTAL amount. I.e. something like this:
CORP:
COAST: NEW | OLD
-------------------------------------
EAST |
SUM OF TOTAL | 6 |
SUM OF DONE | 4 |
SUM OF MISSING | 2 |
% DONE | %67|
WEST
SUM OF TOTAL | 6 | 6
SUM OF DONE | 2 | 3
SUM OF MISSING | 4 | 3
% DONE | %33| %50
The formula for % DONE is DONE / TOTAL
I've tried adding another DONE field to the pivot table (i.e. SUM OF DONE2) then setting the value to be % OF, the base field TOTAL and the base value (previous) however that makes % DONE return the value of #N/A. I've tried various combinations of the above however all are returning the same #N/A. I.e. my pivot table is looking like this:
CORP:
COAST: NEW | OLD
-------------------------------------
EAST |
SUM OF TOTAL | 6 |
SUM OF DONE | 4 |
SUM OF MISSING | 2 |
% DONE |#N/A|
WEST
SUM OF TOTAL | 6 | 6
SUM OF DONE | 2 | 3
SUM OF MISSING | 4 | 3
% DONE |#N/A| #N/A
I've tried Googling how to do it but still to no avail. Please let me know if what I am looking for is possible.

On the Analyze tab, add a Calculated field with the formula
= 'DONE'/'TOTAL'
There is an option in Pivot Table Options that allows you to show blank if there is an error, so you don't get an N/A for old/east. You can go into field settings and format the field as a percentage.

Related

Excel - COUNTIF(s) & SUMPRODUCT

I'm trying to count clusters of values in one column but only if a value in another column is above a certain value.
I started with the below code to count how many unique clusters were in a column.
=SUMPRODUCT(1/COUNTIF(B1:B10,B1:B10))
| A | B |
| -------- | -------------- |
| 50 | 1 |
| 200 | 1 |
| 190 | 2 |
| 10 | 5 |
| 100 | 1 |
| 70 | 5 |
| 130 | 2 |
| 10 | 5 |
This would return a value of 3 as there are 3 unique clusters (1,2,5)
However, I am wanting to add a dependacy based on column A. Only count clusters in B if A>100. As there are no values of 5 in column B where A>100, the cluster count in B would be 2.
Any help to achieve the above would be very much appreciated!!
For any version:
=COUNT(1/(FREQUENCY(IF(A1:A8>100,B1:B8),B1:B8)))
array entered (with Ctrl+Shift+Enter) if non-365. If you have 365 use JvdV's answer. :)
With Microsoft365:
=COUNT(UNIQUE(FILTER(B1:B8,A1:A8>100,"")))
With older versions:
=SUMPRODUCT((A1:A8>100)*IFERROR(1/COUNTIFS(A1:A8,">100",B1:B8,B1:B8),0))

Show top 3 from list based on difference

I have 2 lists;
"yesterday" and "today".
As rows I have a list of companies and the data shown is customer satisfaction going from 0-10. I want to show the top 3 companies that has the best difference between "yesterday" and "today".
How would you approach this??
Expected output looking for top 1:
Yesterday - Today
Company A: 5 10
Company B: 7 8
Company C: 8 6
Top 1: Company A (Since they moved the most(5 positive points))
Assuming your data is like this:
#########Sheet1<YESTERDAY>########
| A | B |
1|Companies| Customer satisfaction|
2|Company1 | 6
3|Company2 | 3
4|Company3 | 4
5|Company4 | 1
6|Company5 | 9
###########Sheet2<TODAY>##########
| A | B | C | D |
1|Companies| Customer satisfaction|Absolute changes | RANK |
2|Company1 | 1 | | |
3|Company2 | 7 | | |
4|Company3 | 7 | | |
5|Company4 | 4 | | |
6|Company5 | 8 | | |
Put this formula into Cell C2to get absolute change:
=ABS(VLOOKUP(A2,YESTERDAY!$A$2:$B$6,2,FALSE)-B2)
Put this formula into Cell D2to get Rank:
=RANK(C2,$C$2:$C$6,0)
So, 1,2,3 in Column RANK are best changes.
I assume best difference as highest difference.run a loop and take the first row company from yesterday as well as the customer satisfaction value and search that same company in today in another inner loop and find the difference of the two values and save it in an array.After that sort the array and display the top 3.

powerpivot using a calculated value in another calculation

I have the following tables
Orders:
OrderID|Cost|Quarter|User
-------------------------
1 | 10 | 1 | 1
2 | 15 | 1 | 2
3 | 3 | 2 | 1
4 | 5 | 3 | 3
5 | 8 | 4 | 2
6 | 9 | 2 | 3
7 | 6 | 3 | 3
Goals:
UserID|Goal|Quarter
-------------------
1 | 20 | 1
1 | 15 | 2
2 | 12 | 2
2 | 15 | 3
3 | 5 | 3
3 | 7 | 4
Users:
UserID|Name
-----------
1 | John
2 | Bob
3 | Homer
What I'm trying to do is to sum up all orders that one user had, divide it by the sum of his goals, then sum up all orders, devide the result by the sum of all goals and then add this result to the previous result of all Users.
The result should be:
UserID|Name |Goal|CostSum|Percentage|Sum all
---------------------------------------------------
1 |John | 35 | 13 | 0.37 |
2 |Bob | 27 | 23 | 0.85 |
3 |Homer| 12 | 20 | 1.67 |
the calculation is as follow:
CostSum: 10+3=13
Goal: 20+15=35
Percentage: CostSum/Goal=13/35=0.37
Sum all: 10+15+3+5+8+9+6=56
Goal all: 20+15+12+15+5+7=74
percentage all= Sum_all/Goal_all=56/74=0.76
Result: percentage+percentage_all=0.37+0.76=1.13 for John
1.61 for Bob
2.43 for Homer
My main problem is the last step. I cant get it to add the whole percentage. It will always filter the result so making it wrong.
To do this you're going to need to create some measures.
(I will assume you've already set your pivot table to be in tabular layout with subtotals switched off - this allows you to set UserID and Name next to each other in the row labels section.)
This is what our output will look like.
First let's be sure you've set up your relationships correctly - it should be like this:
I believe you already have the first 5 columns set up in your pivot table, so we need to create measures for CostSumAll, GoalSumAll, PercentageAll and Result.
The key to making this work is to ensure PowerPivot ignores the row label filter for your CostSumAll and GoalSumAll measures. The ALL() function acts as an override filter when used in CALCULATE() - you just have to specify which filters you want to ignore. In this case, UserID and Name.
CostSumAll:
=CALCULATE(SUM(Orders[Cost]),ALL(Users[UserID]),ALL(Users[Name]))
GoalSumAll:
=CALCULATE(SUM(Goals[Goal]),ALL(Users[UserID]),ALL(Users[Name]))
PercentageAll:
=Orders[CostSumAll]/Orders[GoalSumAll]
Result:
=Orders[Percentage]+Orders[PercentageAll]
Download - Example file available for download here. (Don't actually read it in Google Docs - it won't be able to handle the PowerPivot stuff. Save locally to view.)

Count distinct occurrences and averages in a column based on identifiers in another column

In MS Excel, I want to count the number of distinct categories (ignoring a specific item) based on a different column. Also, I want to find the average and the max for the same selection. This is the data:
+--------+-----------+-------+
| Person | idea | score |
+--------+-----------+-------+
| George | vacuum | 9 |
| George | box | 6 |
| George | x | 1 |
| Joe | scoop | 4 |
| Joe | x | 1 |
| Joe | x | 1 |
| Joe | scoop | 4 |
| Joe | gear | 7 |
| Mike | harvester | 10 |
| Mike | gear | 7 |
| Mike | box | 6 |
+--------+-----------+-------+
The result should be the following:
+--------+----------------+------------+-----------+
| Person | distinct ideas | Avg. score | Max score |
+--------+----------------+------------+-----------+
| George | 2 | 5.3 | 9 |
| Joe | 2 | 3.4 | 7 |
| Mike | 3 | 7.7 | 10 |
+--------+----------------+------------+-----------+
Because Joe has two "scoop" and one "gear" idea, and I want to ignore the "x" items.
I reluctantly gave up and did it manually for each person, e.g., this is for the first person:
SUM(IF(FREQUENCY(MATCH(B2:B4,B2:B4,0),MATCH(B2:B4,B2:B4,0))>0,1))-IF(COUNTIF(B2:B4,"x")>0,1,0)
Doesn't Excel have functions to return a range instead of a value? If I could select the range based on the name of the person in the first columns, I could count distinct occurrences or find the average in another column.
Add a 4th column and label it Distinct Ideas
If your table starts in A1, then:
EDIT: Formula changed to exclude "x". Screen shot also changed
D2: =IF(TRIM($B2)="x",0,IF(SUMPRODUCT(($A$2:$A2=A2)*($B$2:$B2=B2))>1,0,1))
and fill down.
Then construct a Pivot table
Person to Row Labels
Distinct Ideas to Values area
score to Values and select to Average
Score to Values area and Select Max
Format as desired. Here is one result:

Can I populate a column with conditional data while omitting empty rows or possibly autosort?

In one spreadsheet document, file.xlsx, I have 2 sheets. Sheet1 has the editable fields. Sheet 2's sole purpose is to read the data from Sheet1.
The point is to keep track of inventory and easily display items needed to be ordered.
Sheet1 'column a' is item number for ordering
Sheet1 'column b' is the number I have on hand
Sheet1 'column c' is the formula cell to find the number needed to be ordered
It looks something like this:
Document1:sheet1
A | B | C |
1 |txt1 | 1 | =10-b1 |
2 |txt2 | 0 | =10-b2 |
3 |txt3 | 13 | =10-b3 |
4 |txt4 | 5 | =10-b3 |
5 |txt5 | 2 | =10-b4 |
There is some if statement conditional formatting in the "C" column to check if the "B" column has a value HIGHER than 10 and if it hits true then the corresponding C cell is blank but for space, i'm summarizing here
Document1:sheet2
A | B |
1 |=if(sheet1!C1>0,Sheet1!A1,"") |=if(sheet1!C1>0,Sheet1!C1,"") |
2 |=if(sheet1!C2>0,Sheet1!A2,"") |=if(sheet1!C1>0,Sheet1!C2,"") |
3 |=if(sheet1!C3>0,Sheet1!A3,"") |=if(sheet1!C1>0,Sheet1!C3,"") |
4 |=if(sheet1!C4>0,Sheet1!A4,"") |=if(sheet1!C1>0,Sheet1!C4,"") |
5 |=if(sheet1!C5>0,Sheet1!A5,"") |=if(sheet1!C1>0,Sheet1!C5,"") |
If an item isn't to be ordered because stock is high, it doesn't show up in the list. This is ok. It looks like this:
Document1:sheet2
A | B |
1 | txt1 | 9 |
2 | txt2 | 10 |
3 | | |
4 | txt4 | 9 |
5 | | |
What I would like to see is:
Document1:sheet2
A | B |
1 | txt1 | 9 |
2 | txt2 | 10 |
3 | txt4 | 9 |
4 | | |
5 | | |
For 5 Items in the example, it doesn't seem that annoying, but in actuality I have 1200 potential rows and it varies between 200 to 800 actually populated each time i conduct inventory. The whole point is to have one continuous section of rows that I can select and print. Maybe some way of autosorting and placing the empty ones on the bottom?
I've taught myself excel. I don't know the advanced tricks and things.
I'm a typically a programmer but I've been tasked with this project and the guys upstairs want me to do it in excel.
i've overcomplicated this, to the max.
a simple sort putting the empty's at the bottom is the resolution.
not quite as automated as i'd like
but
it works.

Resources