I have input data as below
Who|Day|Eat
Papa|Monday|Milk
Mama|Monday|Water
Papa|Friday|Bread
I want to get summarize table as below, I'm trying pivot table but it's not show the values, it's show count of it.
Name|Monday|Friday|GrandTotal
Mama|Water||1
Papa|Milk|Bread|2
I don't think you'll be able to get the exact output as you'd like it using a pivot table. The two options would be:
Using a pivot table, but changing the format: Place the "who" and "eat" as row fields, and "Day" as the columns field. Then put either "who" or "eat" as the values field.
Manually building the pivot table you would like: You could manually build a pivot table using vlookup or index(match()). I would do this by creating a lookup variable (Who&Day ==> e.g. PapaMonday, PapaFriday), then doing the appropriate lookup. Let's say this lookup variable is setup before the data table (so in column A, and Who is column B, etc.). It would look something like:
Column A|Column B|Column C|Column D
Name|Monday|Friday|Grand Total
Mama | vlookup(A2&B1,sheet1!A:D,4,0) or index(sheet1!D:D,match(A2&B1,sheet1!A:A,0)) | vlookup(A2&C1,sheet1!A:D,4,0) or index(sheet1!D:D,match(A2&C1,sheet1!A:A,0)) | {Number of days}-countblank(B2:B3)
and so on and so forth. This is a pretty brute force method of doing it however.
Related
I have a pivot table like the one in the image:
The table updates every month.
The question is: how can I dynamically get the last value of the table with a function, without VBA?
For example, in this case the last value is -32, just above the "Grand Total" value.
I'm considering to use the function "GETPIVOTDATA" but I don't know how to change the dynamic reference to the last value inserted. At the moment, the formula looks like this:
=GETPIVOTDATA("[Measures].[Count of DESIGNER]";$A$3;
"[Components_Drawings_Data].[DATE (Month)]";
"[Components_Drawings_Data].[DATE (Month)].&[giu]")
Screenshot (below) / here refer.
Assuming:
You can isolate the pivot table so that there are no populated cells
beneath it (reasonable premise, given it's 'dynamic' and so variable
re: # rows)
You're not fixated upon using a PivotTable reference in formula
You do not anticipate any row labels = 'Grand Total' (which would be unusual to say the least, however see alternative function below)
Grand total for columns is displaying
Then the following will achieve what you have indicated:
...how can I dynamically get the last value of the table with a
function, without VBA?
=OFFSET(INDEX($F$4:$F$100,MATCH("grand total", LOWER($F$5:$F$101),0)),0,1,1,1)
Note: the formula in cell L3 in above screenshot includes a wrapper for presentation / ease of use only - i.e. 'Item' (col J) refers to the number of cells 'up' from the Grand Total at the very bottom of the pivot table... e.g. for item = 1 (one level up), 119 is returned (corresponding to 'woman'); for item = 2 (two levels up, 77 displays and so forth.
The corresponding label can be determined in a very similar fashion:
INDEX($F$4:$F$100,MATCH("grand total", LOWER($F$5:$F$101),0)-J3+1)
Alternative/direct (does not rely upon Grand Total for cols):
=OFFSET(F3,COUNTA(F3:F100)-2,1,1,1)
I elaborated this trick.
Suppose the column "Month" of the pivot table corresponds to column A, and the column "Delta" to column B.
I would use this formula:
=INDEX(B:B;MATCH("Grand Total";A:A;0)-1)
It could work.
These are the individual data points of the data model:
These are the monthly salaries of the employees (obtained using the pivot table from the data model's data):
Each cell will then be used as the Lookup value which will be run through a table.
The lookup value is to be looked up in column A and column B of the table below and if it is matched (within the range), it will return the corresponding value under column C.
I am unable to find any index and match or vlookup functions in the power pivot functionality of excel using measures--which are used to get some analytics on aggregated values on report objects such as pivot tables.
I have found LOOKUPVALUE( <result_columnName>, <search_columnName>, <search_value>[, <search_columnName>, <search_value>]…) which is a DAX function however, the issue here is that I am doing a range lookup and as shown below, I don't know if you can have an array as an argument to the function.
Traditional calculated fields also do not allow arrays in the formulas.
Lookupvalue() only works on a single column lookups because it will return an empty cell if it cannot find a match as shown below:
But when it does find a match using the table below:
It will work just fine:
First, you need to create a measure for Pay:
Total Pay = SUM(Table1[Pay])
It's important to do it as a measure instead of just dropping 'Pay' into a pivot table (this is called an 'implicit measure' and is concidered a bad practice).
Then, let's say your table with pay ranges is named "Pay Ranges". Create another measure:
Returned Value =
CALCULATE(
VALUES('Pay Ranges'[Value To Return]),
FILTER( 'Pay Ranges',
[Total Pay] >= 'Pay Ranges'[Lower Bound] &&
[Total Pay] < 'Pay Ranges'[Upper Bound]
))
Make sure that all these formulas are Measures, not calculated columns.
Also, the formula relies on the correct construction of the ranges. If they overlap, you will get an error.
I am using Excel from Microsoft Office 365 ProPlus.
Here's a really simple data table.
I want to build a Pivot Table around it to look like this...
... except that the "what I want" column (which is the count of items in Column C divided by the count of items in Column B) should be a part of the pivot table.
I have tried all sorts of things using calculated fields, calculations on fields, etc., to add the "what I want" column and just cannot make it work.
Can anyone help?
Calculated Fields only operate on the Sum of the elements in the data tables. Wherever you see a Field Name in the formula for a Calculated Field, picture it as meaning the sum of all elements for that field (that match any other row/column criteria in the Pivot Table).
Putting "= B / C" actually means "= SUM(B) / SUM(C)" for elements of columns B and C that fit that section of the Pivot Table.
The only way to achieve your goal is with two helper columns:
B Count: =COUNT([#B])
C Count: =COUNT([#C])
The sum of these columns then give you the count of columns B and C, so you can use these helper columns to give you what you want:
The Data Field based on the Calculated Field then says "Sum of What U Want", but it will always just be the result of your calculation, even if you change how the field is summarized through Value Field Settings. You can manually rename the Data Field, but it still needs to be different to the Calculated Field name you chose earlier.
Click in the Pivot Table, then go to the Analyze tab, click on Fields, Items, & Sets, then select Calculated Field. Your formula is probably
= B / C
I have a table A that contains ID (i.e. SR1000). Also a table B with two rows, another ID (i.e. C-1) and text on the second row.
I was trying to use VLOOKUP using the ID on table A to return ID on Table B if ID from Table A is somewhere in the text of column 2 in table B.
Table A
SR1000
SR1001
Table B
C-1|dummy text
C-2|dummy SR1000 dummy
So it should return C-2 when looking for SR1000.
Is VBA my only option? Trying to avoid reinventing the wheel.
It seems the formula:
=INDEX(F:F,MATCH("*"&B4&"*",G:G,0))
has been deemed fit for purpose and by way of explanation this was based on assumed locations as below:
In Microsoft Excel, how can I compute a range (portion of a column), based on the values in another column of the same table, returning the result in an Array form for further processing by other functions?
In SQL, what I mean is "SELECT field1 FROM table WHERE field2=value".
The selected results will be fed (twice) to FREQUENCY(), to compute the number of distinct entries in "field1". That is: given an existing table like this:
Box Date
1 07/01/12
13 07/01/12
13 07/01/12
27 07/18/12
13 07/18/12
55 07/18/12
I want to produce a resulting table like this:
Boxes Date
2 07/01/12
3 07/18/12
Note that "13" is only counted once in the first date ("distinct"), but it's still counted again in the second date.
I already have an expression that does the right thing for the whole of the table,
=SUM(N(FREQUENCY(Box,Box)>0))
where "Box" is a named range of the first table, consisting of the whole Box column. (Using the same range/array/list as the data and the bins for FREQUENCY is a stupefyingly subtle trick actually contained in the Excel help but -- alas! -- by no means adequately explained.)
But I want (several) subsets, one for each date. I want to expand my "SUM(N(FREQUENCY…" expression to act only on the rows of the first table whose Date column matches the Date column of the row being computed. That is, again resorting to SQL,
SELECT count(DISTINCT t1.Box), t2.Date
FROM `t1` JOIN `t2` ON (Date)
GROUP BY Date
I can even build a pivot table of the interesting values (which gets me counts in its cells), then use a parallel, date-indexed column of
=COUNTIF(…)
to reduce each row of counts down to a single count of uniques for that date. But this requires me to update the pivot table to notice new data in the base table, and then to drag-expand the column of answers to include the new date (or suffer ugly value error markers). So something more automatic, less fussily manual, would be sweet.
I guess not available when you asked, but Excel 2013 has Distinct Count as an option in a PivotTable: