passing parameter to build a dynamic string in excel - excel

My requirement is very simple but i am not finding it easy-
In excel, column A is having 'Table name' and column B is having 'Column name'
I want to write a query-
Select * from 'column A' where 'column B' is not null.
In excel I have 2578 lines so I dont want to write 2578 Select statements.
any expert help in Excel?

I doubt this is your answer, but may help towards what you want. Based on #user3514930's approach:
With data as in the top left corner, select the two columns and click on DATA > Sort & Filter - Filter. Click on the arrow in the Column name cell and on (Blanks) in the dropdown. You should then see the equivalent of what is in the lower range. This can be copied and pasted elsewhere in the sheet, if you wish.

Related

ungrouping Excel data saved as an Outline as a pivot table

I do not know if it is possible to do what I want to achieve in Excel, but I have the data that is generated in the Outline (let's assume: on the left side of the screen I have a "plus", if I press it, I have another "+" and I get to the next detailed data.
The problem is, when I ungroup it all, I have every item in column "A" and I can't make it into a PivotTable.
What I mean?
Example (you can see it in the photo).
1 "plus" - country:
[![enter image description here][1]][1]2 "plus" - city:
3 "plus" - brand of items sold
4 "plus" - exact equipment from this brand
When I ungroup it, everything is in one column and it should be - respectively - 1 "plus" - column A, 2 "plus" - column B, etc.
Is there any possibility to ungroup it according to the "pluses".
I hope there is any sollution...
Thanks
See https://www.mrexcel.com/board/threads/calculating-outline-levels-in-excel.227279/#post-1112028 copied here:
Select cell A1 of the sheet,
Do menu command Insert/Name/Define, and create a name called DetailLevel, with a formula ( in the Refers To box ) of:
=GET.CELL(28,Sheet1!A1)
( alter the sheet name Sheet1 to whatever your sheet is called )
Now in any blank column of the sheet type the formula =DetailLevel and copy down.
That will give you 1 for no indent, 2 for level 2, 3 for level 3
bring that along as data column to create pivot table

How to add each row in one column just like excel in Power BI?

For instance: I have value 5 in cell A1 and when I do =5+A1 in excel it will do the job for the rest of the columns. How can I do exactly same in PowerBI? could anyone help me with this?
Thanks
Go to Table mode and click New Column.
Type MyColumn = Rates[size] + 5
Where [size] is base column as input (like A in excel) and MyColumn is the name of your new column.

Create dynamic search box instead of Ctrl + F

I’d like to create a dynamic search box at the top of my master sheet (Sheet 1) instead of using the “Find” command, Ctrl + F. It would search column B and output info from the corresponding cell in column C.
The search box/cell would be dynamic, so as I type into it, it would pre-populate from a master list (Sheet 2), without having to hit ENTER or an OK button.
I’d like the search box/cell to be in A1
I’d like it to search column B data. From B2 to the end (row can change): B2:B
The result would be the data in column C:C2:C
Not sure if I should use the QUERY or ARRAYFORMULA function. Appreciate any thoughts on how to set this up.
how about this:
=JOIN(CHAR(10), QUERY({B2:C}, "select Col2 where Col1 contains '"&A1&"'", 0))
demo spreadsheet
I think I figured it out!
Sample Sheet
Search Box (A1): I used Data Validation. It is dynamic as I type and lists the master list of items in column A
Search Results (B1): I used VLOOKUP
Thanks, #player0, for suggesting the data validation! Really helped :)
Only issue is that I sometimes have multiple values in Column B (Item). For instance, I have "lemon" listed twice. I'd like the output in B1to show all other results. They can show in B2...Any suggestions?
EDIT: For the issue of multiples in column B, I decided to change all items in Column B to a unique identifier.
paste this in C2 cell:
=QUERY({B2:B}, "where Col1 contains '"&A1&"'", 0)
and set up dropdown data validation from B2:B range in A1 cell
demo spreadsheet

How to find the value of column name and row name when a value at the intersection is matching a condition

How to find the value of column name and row name when a value at the intersection is matching a condition
I have this data
TC1 TC2 TC3
TC1 100 87 95
TC2 88 100 99
I need to return the combinations where value is greater then 95 like:
TC1,TC1 TC1,TC3 TC2,TC2 TC2,TC3 and so on.
Can anyone help here?
This is for Excel 2016.
So, you've got your data:
Highlight it, and then click 'Format as Table' from the Styles Group in the Home ribbon. (yes, your table has headers)
With this table in focus, navigate to the 'Data' ribbon, and click 'From Table/Range' in the 'Get & Transform Data' group. This will open the query editor. If you're not used to it, don't worry. Although it can get quite complex in here, we're going to be pretty straightforward.
Highlight columns TC1, TC2, TC3 (Hold down [control] and click each column header). Go to the Transform ribbon, and click on 'Unpivot Columns' in the 'Any Column' group. Look at what happens, it's awesome.
Now, click the arrow next to the Value column. Go to 'Number filters' on the drop down. Pick, 'greater than equal to.' A 'Filter Rows' dialog opens. next to 'is greater than or equal to' put in 95.
Click OK. Your data set is filtered. Yes! Go back to the home tab, click 'Close & Load'
Admire your gorgeous list of tuples for values greater than 95.
Good luck! Hope it helps.

How can I make a drop down list that stores an index value in a hidden field?

I have an Excel spreadsheet where on Sheet 1 the Department Id is represented as a number and where on Sheet 2 there is a list of those numbers with the Department Name next to them.
If possible I would like some help and advice as I want to allow the user to select the Department Name from a drop down list and have it populate a hidden field with the department number.
Something like in Sheet 3 with the Department Id being stored for example in the C column on that page:
Sheet 1
Sheet 2
Sheet 3
This could be one approach.
If I have understood you correctly, the user will select the department name in a drop-down list in Sheet 3 and and the index number associated with that department name will appear. The user will not be limited to what name (andy, bob) it is in the adjacent column...
Result will be (notice this is a Excel Table!) :
We have the 3 sheets:
Select the data areas and click on "Format as Table", Select the option "My data has headers". Do this for all the 3 sheets.
Name your tables: "Design" -> "Table Name". I will use "Table1" for "Sheet1", "Table2" for "Sheet2" etc. It will make life easier when you link and refer in formulas. Notice that for "Sheet3" I also add a dummy column C. I name it "Index Number".
Go to "Sheet2" and select the range that you want to use as your drop-down list (in my case i choose Department Names and selected "B2:B8". Click "Formulas" -> "Name Manager" -> "New..."
This window will pop-up. Name it an easy name (I named it: "Department_Names") and check that the "Refers to:" is in this format "=TableX[Column Name]". In our case =Table2[Department]. Notice that the name manager don't use "B2:B8", rather is reference to the table column area. The last step is very important!
Go to Sheet3. Click on cell where you want to apply the drop-down list (I use B2 in the example). Click "Data" -> "Data Validation".
Data Validation window will now pop-up. Go to "List" and in the field "Source:" you write your named range as =Department_Names (the one I named "Department_Names"). The drop-down list will use the values in the range that "Department_Names" are applied to. In our case it will make a drop-down list of all the department names from "Sheet2", range B2:B8.
Go to "Sheet3" and enter the formula below in the cell C2 as shown in the picture.
Notice I use " ; "as delimiter (European version of Excel, US user will probably use" , ").
=IF([#Department]="","",IFERROR(INDEX(Table2[ID],MATCH([#Department],Table2[Department],0)),))
The first part creates our Index number:
...IFERROR(INDEX(Table2[ID],MATCH([#Department],Table2[Department],0)),)
Return the Index number from "Table2", Column ID. INDEX(Table2[ID]
lookup value in the MATCH formula comes from "Table3", Department
(drop-down list)
The lookup value will look in "Table2", column Department.
Will take care of 0 that will be created when nothing is selected in the "Table3", Department column (see next picture for example)
=IF([#Department]="","", ...formula...)
Formula without the =IF([#Department]="","", ...formula...)
You can hide the "Index Number" column in "Sheet3" if you don't want to have it visible.
Right click on the Column C header and choose "Hide".
Only for demonstration purpose here. I create a dummy column "Only for show hidden column values". So when the user selects a Department name, it will change the index number associated to that department.
So why the use of tables and named range?
Let's say you need to add a new department. We add a department in the "Table2" and we give it ID: 7 and Department Name: Department H.
What happens in your "Sheet3" is that the drop-down list will automatically catch the new row. The range named to "Department_Names" will adjust to the table rows because it's linked to "Table2[Department]". This is also true if you decrease rows for Table2. Source
I have not tested it, but I'm quite sure that you can link a table to an external source. So when you import your data to the table (given the headers is static) the table will be updated with "Refresh All" button in Excel. Something to explore and look further into :)
It can be done with INDEX/MATCH.
As an example:
Sheet1 contains your lookup table.
For simplicity sake Sheet1 has numbers 1 - 6 in the range A1:A6 and A - F in the range B1:B6.
1 - 6 are the primary keys and A - F are the descriptions.
Sheet2 has Data Validation in column A: Allow List using =Sheet1!$B$1:$B$6 as the Source. This will give you the drop-down in column A.
In column B, which is hidden, you have the formula =IFERROR(INDEX(Sheet1!$A:$A,MATCH($A2,Sheet1!$B:$B,0)),"")
The MATCH formula will return the row number in Sheet1 that the description appears in.
The INDEX formula will return a reference to the cell in column A on that same row - giving the Primary Key value.
If no match is found then #N/A is returned which is dealt with by the IFERROR statement.
This method will work if your departments are less than equal to 32.
In UTF 8 characters from code 128 to 160 are hidden (among many others). You can use these characters as your id key, you have to just concatenate them with your department name.
This is a screenshot of excel
3rd column is the Unicode character, 4th is concatenation of this character and the department name and last column is extracted id from the new department name.
These are the formulas
At the end it can also work if your departments are more than 32 but you have to find another slot of non-printable characters
You have to use the new department names as data validation drop downs where department entry is required and can extract the id from the entered department

Resources