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
Related
I have been trying to populate the following table:
with order_amount from the following table:
I cannot crack the fact there is a second condition to be taken into account - column delivery_week.
Can somebody please help me out with a formula so it can be used across the weeks in table Final?
I have tried with Index+Match. The issue is, one condition is to be looked up horizontally (product_id) and second (Deliver_week) vertically
The end result is shown here:
I would appreciate any tips..
PS: The table structure has to stay as it is - shown tables are just necessary columns to solve the problem.
as stated in the comments use SUMIFS. Put this in C2:
=SUMIFS(OtherSheet!$C:$C,OtherSheet!$A:$A,$A2,OtherSheet!$B:$B,C$1)
And copy over and down.
In the order_amount table, try to create in D:D an assisting column which concatenates both columns A and B, i.e. (A2&B2).
Go into columns C2 in your target table and write something according the following:
(assuming order_amount is in worksheet - "sheet2")
=INDEX(Sheet2!$C:$C,MATCH($A2&C$1,Sheet2!$D:$D,0),0)
Pull this formula to the other rows and columns to populate them, the formula is fixed, thus don't worry for changes. To replace N/A with "0" use:
=IFERROR(INDEX(Sheet2!$C:$C,MATCH($A2&C$1,Sheet2!$D:$D,0),0),0)
This may be a weird request. I'm dealing about 100-250 rows for my case.
A simplified example screenshot:
I am using vlookup (column G & H) to assign the values based on Master sheet table.
But I was wondering if there is a way to include a formula for "checker" column to indicate if the values from vlookup are assigned correctly in G and H.
One way would be:
=IF(COUNTIFS($A$1:$A$5,E1,$B$1:$B$5,F1,$C$1:$C$5,G1)>0,"OK","Nope")
or without countifs:
=IF(SUMPRODUCT(($A$1:$A$5=E1)*($B$1:$B$5=F1)*($C$1:$C$5=G1))>0,"OK","Nope")
This doesn' check for duplicates in the first list. A simple countif could do that job
I want to filter a table in excel and return a different column to create a list for data validation.
My table contains a list of names and one of the columns is a Yes or No for being an admin.
I want to create a data validation list on another sheet and use the filter table to just show those names that have a Yes in their associated row in the table.
I recorded a macro to filter the table to show just the rows I need and now want those names to appear in the list.
ActiveSheet.ListObjects("Staff").Range.AutoFilter Field:=8, Criteria1:="<>"
Is this possible?
I had tried using the =FILTER() formula but it's not available in my version of Excel.
I'd prefer to do it with a formula in the validation settings rather than VBA.
This is something of a faff but I think it works, though by no means the best way of doing it.
Table of data on the left.
The "Yes" names are listed in D1 and down, the formula is an array (use Ctrl, Shift and Enter to confirm). I'm sure someone cleverer than me can shorten this.
=IF(ROWS(D$1:D1)<=COUNTIF(Table1[Admin],"Yes"),INDEX(Table1[Name],SMALL(IF(Table1[Admin]="Yes",ROW(Table1[Name])-ROW($A$2)+1),ROWS(D$1:D1)),1),"")
E1 is just the total of the names shown in D (another array formula):
=SUM(IF(LEN(D:D)>0,1,0))
The DV is in G1 and the formula there is
=OFFSET(D1,0,0,E1,1)
If you change e.g. Sarah to Yes, her name will appear in D and will be added to the DV list.
Once you've applied your filter to column 8, you can select the range that remains visible in a different column using:
ActiveSheet.ListObjects("Staff").Range.Columns(8).SpecialCells(xlCellTypeVisible).Offset(0, -2)
This would return a range consisting of column 6 (8-2) of your table. Adjust to suit your needs.
You could then cycle through that range one cell at a time and populate a new range from it, accordingly.
I have 2 different worksheets like these
I need to have a new summary sheet with the Time spent sum.
Here should be the output:
What is the best way to implement the formula?
I've simulated your situation, creating two tables, one in sheet1, one in sheet2, containing information in cells B3:C5, and I came up with this formula:
=SUM(VLOOKUP(B3;Sheet1!$B$3:$C$5;2);VLOOKUP(B3;Sheet2!$B$3:$C$5;2))
You might get this to work in your situation by creating an extra column, where you concatenate first name and last name (in order to get the VLookup() to work), but I sincerely think there should be easier ways to get this done.
For your information, my table looks as follows:
A B C
1
2 Name Number
3 a X
4 b Y
5 c Z
The mentioned formula gave the sum of the Xs, Ys and Zs.
Lets say i have two sheets:
Sheet 1:
Sheet 2:
In my opinion the easiest way is:
Select the cell you want to paste the results
Go to Data - Data Tools - Consolidate
Press the arrow at Reference: select the first range, press enter and press Add. Do the same for the second range.
Select Left column and press OK
Structure:
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)