Equivalent of SELECT FROM WHERE on Excel - excel

I have a dataset on an Excel table in which each line has an Id and several other columns.
in some others sheets I need to select some columns depending on the given id.
I am using Excel 2016, so I've tried the "dget" function but it seems not to be the best solution.
For the dataset it's close to this:
id Name birth date gendre
1 Sara 10/05/1997 F
2 Edward 01/08/1994 M
3 Anna 06/10/1993 F
and for getting data I use
=DGET(Table1[#All];Table2[[#Headers];[Name]];A1:A2)
in each column (A1:A2 here is for id and 2)
id Name salary
2 Edward 5000
and then I add some new columns that I don't want them to be in the first dataset.
This solution works only for the first row since it requires a the Criteria (last field in DGET function) to be a range, the official definition:
Criteria Required. The range of cells that contains the conditions that you specify. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
Starting from the second row the Criteria is not a range anymore it is like "A1;A3" (for the 1st row "A1:A2")
Is there any other solution or alternative to do so?

Select a cell in the Table, click Insert>PivotTable, then drag the ID, Name, BirthDate, and Gender fields into the ROWS area. Then add a Slicer on ID, Name, and Salary by clicking in the PivotTable and selecting Insert Slicer. Then choose the ID/Name/Salary values you want. To make multiple selections, hold down Ctrl or click the MultiSelect button of the Slicer.

Related

How to sum over criteria in Excel?

Let's say I have a table of First/Last names and Salaries.I want to compute, for every last name, the sum of the salaries of people with that name.
I know how to do that for each name individually using SUMIF, but I was wondering if there is a quick function to produce a table of Last names and Salary sums?
Another option would be using a pivot table.
On the insert tab, select pivot table
Use your existing table as the data
In the fields select the Last Name and Salary columns
Let's support you have the salary sheet in sheet1 as below,
copy column last name value to sheet2.column A, remove duplicate, add a new column as Salary Sum in column B, input a formula as =SUMIF(Sheet1!B:B,Sheet2!A2,Sheet1!C:C) and drop down to all rows, then you can got a salary sum table as below,
of course, if the first name/last name is dynamic and unexpected, it would doesn't work. you can drop a button and bind a VBA code to handle it.
You could use this ARRAY FORMULA: CTRL + SHIFT + ENTER
=IFERROR(INDEX($A$2:$A$7,MATCH(0,COUNTIF($D$1:D1,$A$2:$A$7),0)),"")
For summing up the corresponding values just use
=SUMIFS($B$2:$B$7,$A$2:$A$7,D2)

Update column based on dropdown selection

I have 2 sheets on Google Sheets. In the first sheet I have multiple columns which are repeated, where for every 2 columns, the first one is the product name, and the second one is the quantity sold for each of the products. What I will do on this sheet is select the product that the customer bought on the dropdown, and insert the quantity bought in the next cell. I need multiple columns as some customer buy multiple product types at one time.
Then in the second sheet, I want to tabulate the quantity for each products which is predefined in the header. This is meant to be automated.
Sheet 1
Sheet 2
Below is the link to a sample file.
https://docs.google.com/spreadsheets/d/151D6-QE_ePOyPEeMfMO9GSOQrFVQ5AbsagOaQUm_2eU/edit?usp=sharing
Can anyone help me with getting the qty populated on the matrix table based on the qty input next to the dropdown list? The closest that I got is using below formula, but the quantity is always based on the first dropdown qty only.
=IF(SUMPRODUCT(--(C$2 = {product!$C4,product!$E4,product!$G4,product!$I4,product!$K4})) > 0, -1*product!$D4,"")
I guess a good starting point would be how to get the address from Sheet1 that have the value corresponding to the table header in Sheet2.
Heres how I would do it
I'd use an index with match the "Ref ID" Row and the "product" Column (offset by +1 for the value)
Then to make the results dynamic to the "Ref ID" I put an indirect range reference matching the "Ref ID". I then wrapped it in an IFERROR then 0 if it doesnt have a product within a Ref ID.
Hope this makes sense, I'm sure the example below will make more sense than me :)
Code to go in C4
=IFERROR(-index(Sheet1!$1:$607,match($A4,Sheet1!$A:$A,0),match(C$3,indirect("Sheet1!$"&match($A4,Sheet1!$A:$A,0)&":$"&match($A4,Sheet1!$A:$A,0)),0)+1),0)
Example on Sheet 2:
https://docs.google.com/spreadsheets/d/1eeonWF8gcvQdDrTlydmHiMzr9MZpRDAkX_fZBX95yaI/edit?usp=sharing

Excel using proper formula, Lookup vs Vlookup vs IF

Trying to write a formula for Excel, Using 2 worksheets. to classify the invoices
Worksheet 1 has Group Name and Group ID
Worksheet 2 has Group Name, invoice amount,invoice number
Trying to get the Group ID to worksheet 2, keeping in mind a ID can be use multiple times
Using formula below but the IDs I'm getting back aren't matching
=LOOKUP(F2,GROUP!C:C,ID!B:B)
Any help would be appreciated
Assuming GroupName is column 1 of Worksheet2 and that GroupName and ID are in columns A and B, respectively in Worksheet1
Place this formula in B1 of Worksheet2:
=vlookup(A1,Worksheet1!A:B,2,0)
Update all cell references and placements as they match your actual sheet data.
With vlookup you have to be sure that your data is first sorted, otherwise the algorithm tends to fail.
A better alternative, in my experience, is to do something like the following. I am assuming that Worksheet 1 has Group Name in Column A and Group ID in column B, and that Worksheet 2 has Group Name in column A. This formula would go in worksheet 2, in a blank column starting in row 2:
=index(Worksheet1!B:B, match(A2, Worksheet1!A:A, 0))
If you fill that equation all the way down, then it will perform the equivalent to a vlookup but without the need to sort your data first.
In Worksheet2:
=Vlookup(F2,Worksheet1!B:C,2,False)
But it would be better to size the table exactly and not refer to the whole column, like:
=Vlookup(F2,Worksheet1!B1:C200,2,False)

Microsoft Excel Spreadsheet filter with cells with multiple values

We all know how the auto filter of Excel spreadsheet works: once the auto filter is turned on, a list of distinct values from each cell of a column shows with a checkbox in front of each value.
I am trying to find out if it is possible for one cell to have more than distinct one value and each of them still shows in the auto filter list so that when any one of them is selected in the auto filter, the row with this cell will be selected.
For example, I have a column called "developers". One of the cells of the column has two names, "John, Smith". What should I do so that Johnn and Smith would appear in the auto filter select list, when either John or smith, or both are selected, the row with this cell will be in the result set.
Thanks.
Create two additional columns FirstName and LastName. Parse Developers and load the appropriate value into each of the two new columns with a formula. Autofilter all three columns and set up a custom filter that selects "John" from First name or "Smith" from LastName ...
... or follow pnuts' advice and use contains "John" or "Smith", which is much easier.

Excel Filter : sheet comparison

Excel formula : Suppose we have sheet 1, sheet 2 and sheet 3
In sheet 3:
Pick entity "A1" from sheet 1
Search in "G" column of sheet 2 or (Find All)
Past all rows which contains the same entity to sheet 3
Your sample spreadsheet shows some things that add a lot to your original posting. Column B on the All tab is pretty weird, with strings like $500 $200 $300 in a single cell. Is there no way to separate that into three numeric values across multiple columns? Anyway, assuming that can't be changed ...
The sample spreadsheet shows a series of worksheets each of which extract a subset of rows from the All worksheet based on a sub-string search. A simple solution would be to use pivot tables.
Add column headings like Name and Value to the All worksheet
Select the whole data table in the All worksheet
Insert > PivotTable and choose the "$100" worksheet as the
destination
On the "$100" worksheet, drag both Name and Value to the rows of the
pivot table
Maybe need to change pivot table settings to turn off subtotals and
set Report Layout to Tabular Form
Set the Value filter to Label Filters > Contains > "$100"
The main limitation of this approach is that you have to manually set the substring being searched for each time. Pivot tables do not allow you to include a cell reference in a filter condition.

Resources