how can i set condition inside pivot sum data to refer label row ?
I need to sum data only if row label is equal to specific value.
I'm trying to use standard IF but it doesn't work.
Thanks.
Use a vlookup ( within a vlookup.? Others please say if that is necc). copy paste your row tabels in another column in another sheet/tab and look for them im ur pivot.
Vlookup(a1,sheet2(column),1,0).
Altetnatively u culd just copy paste text only the pivot table results, and use ur if statement there.
But vlookups are superior if statements. So us that is more dynamic/poweful.
I would use a sumproduct function if I were you.
https://www.ablebits.com/office-addins-blog/2016/08/24/excel-sumproduct-function-formula-examples/#Conditionally
To sum Apples sales for North:
=SUMPRODUCT(--(A2:A12="north"), --(B2:B12="apples"), C2:C12)
Related
I have an excel file with hundreds of steps(one on each row) and each column represents a scenario. If that step is executed in the scenario there is a value "x" in the same row.
I would like to extract the data from this sheet to another sheet where for each scenario I would see just the steps executed in it. (a scenarios has a few steps).
Here is a representation of what I would like to do
I tried using advanced filtering function but it did not give me the results i would like and I am not very skilled at writing IF conditions. Any help would be appreciated.
Try this array formula in J3 if your data is as per my screenshot and drag it as required.
=IFERROR(INDEX($A$3:$A$12,SMALL(IF(ISTEXT(B$3:B$12),ROW($A$1:$A$10)),ROW(A1))),"")
You may try to use a pivot table, where rows are the steps and columns are the scenarios. Use scenarios as values and using the count instead sum.
That way you can later on the output sheet use de getpivotdata to fill it.
I am trying to fill in my Summary Table with the data from a pivot table I have created. Within my summary table, I am trying to pull the closing number of the specified stock from the specific day. I believe the VLOOKUP function is the best way to do this, but I keep getting a #N/A. What is the proper way to write the VLOOKUP? My VLOOKUP Function looks like:
=VLOOKUP(C7,'Pivot Table'!$4:$3914,1,FALSE)
Do I need to restructure my pivot table or use an HLOOKUP?
You can use the MATCH() function in the VLOOKUP to find the correct column, but you need to look for the date first then the ticker column:
=VLOOKUP(E$6,'Pivot Table'!$5:$3914,MATCH($C7,'Pivot Table'!$4:$4,0),FALSE)
Then drag it over and down.
OR
If you want to look for the Ticker first you can use a HLOOKUP with a MATCH():
=HLOOKUP($C7,'Pivot Table'!$B:$N,MATCH(E$6,'Pivot Table'!A:A,0),FALSE)
OR
You can use INDEX() with two MATCH()
=INDEX('Pivot Table'!$A:$N,MATCH(E$6,'Pivot Table'!A:A,0),MATCH($C7,'Pivot Table'!$4:$4,0))
You may access the pivotCache directly:
Use the names of your pivot table fields either by :
1) Looking at the names of the fields in the field list
2) referring to your data table and seeing what names you use, or
3) using tabular or outline layout(instead of compact - and the field names wil come up in the rows and columns dropdowns).
Then use:
=GETPIVOTDATA("Close",'Pivot Table'!$A$4,"correctNameofDateField",E$6,"correctNameOfTickerField",$C7)
You can drag this across and down.
Following data structure:
ID CRIT1 CRIT2
1 L M
2 H M
3 H H
I would like to get the IDs with Crit1= H and Crit2=H.
In a second sheet I want to build a table with the IDs which satisfy my criteria. So in this case only 3.
I tried with INDEX/MATCH and COUNTIF.
However, so far no useful solution based on strings and ranges.
I suggest a PivotTable without Totals or Subtotals, in Tabular Form, all three columns as ROWS and filtered to select H for each of CRIT1 and CRIT2:
Here is a formula solution That will create your table without any blanks.
This assumes your source data are in Sheet1. Edit as necessary.
=IFERROR(INDEX(Sheet1!A$2:A$9999,SMALL(IF((Sheet1!B$2:B$9999="H")*(Sheet1!C$2:C$9999="H"),ROW(Sheet1!A$2:A$9999),9E+99),ROW(1:1))-1),"")
This is an array formula and must be confirmed with Ctrl+Shift+Enter.
Now copy downard as far as needed.
Note: adjust the 9999s to a row number suitable to your situation.
Without macros you can only copy the single cells if the criteria are satisfied, and don't copy them if not. Paste this formula in A2, then copy it to right (other columns), and to bottom (other rows):
=IF(AND(Sheet1!$B2="H";Sheet1!$C2="H");Sheet1!A2;"")
Ok so the pivot table does work yes, however I want to plot a graph which seems to be impossible with pivot data model
Regarding the formula solution I don't think it works.
It will give me all IDs with either crit1=h or crit2=h
I have the following sheet:
I then use the following formula to count the number of each type in each area/country:
=COUNTIFS($B$2:$B$19,"UK",$C$2:$C$19,"A") and I get the following result:
My problem is that I only want the same name to be counted once per area/country, therefore the value for UK / A should be 4, not 8. Does anyone know how to accomplish this?
Regards
Crouz
Concatenate your name/location columns and do your countif using that. It's not pretty, but it will do what you want.
I would do a pivot on a pivot. Both should be in classic pivot table format.
Let me walk you through the logic:
1st Pivot
Pivot your initial data. Format pivot to be classic (right click -> PivotTable Options -> Display -> Classic .. -> ok)
As Row labels have Location, Type and Name. in Values put anything you want i have chosen count of Name.
Remove subtotals, grand totals from pivot and Repeat item labels or columns Location and Type(i am assuming you have excel >= 2010). http://www.extendoffice.com/documents/excel/1964-excel-repeat-item-labels.html
2nd pivot
Pivot your 1st pivots data. Pivot to classic view. in Row Labels have Location and Type and in values whatever you want os count i have chosen count of Location. Remove sub/grand totals and repeat items and your done.
This is what i have
Another alternative is to remove the duplicates. On the data tab, click on remove duplicates. It will then all you for the criteria to use. Select all three columns. It should then work as you expect
I have a data table, and this corresponding pivot table:
For each row in the pivot table, I'd like to know which field the row label refers to. So for the highlighted orange cell C17, I would like to return "First Name" (as you can see by hovering over cell A17).
I have some constraints that mean I need to use the pivot table in compact form. It would be easy if I could just use an outline or tabular layout, but I'm restricted to using a single column for my row labels.
Any ideas please? I'm happy to take solutions using either VBA or built-in Excel functions. Thanks!
In the highlighted cell, use the following formula: =IF(ISNA(MATCH(A17,$A$2:$A$7,0)),$B$1,$A$1)
This will work unless the Last Name also is a First Name that appears in your list.