Excel Pivot values as column labels - excel

I am trying to create a Dependent drop-down list in excel using data from a pivot table.
The source data looks like this:
+--------+---------+
| Name | Country |
+--------+---------+
| John | USA |
| Albery | USA |
| Mary | Canada |
| Bob | Canada |
| Alice | Mexico |
+--------+---------+
Using Pivot I am able to fetch the data dynamical in a similar setup. However, in order to create a dependent drop-down lists for an Entire Column like like in this tutorial. I need the pivot to dynamically display data like this:
+--------+--------+--------+
| Canada | Mexico | USA |
+--------+--------+--------+
| Bob | Alice | Albery |
| Mary | | John |
+--------+--------+--------+
Is this even possible using pivot, or is there any other way to achieve this?
Attached Excel file

If you have Excel for Office 365 (or Excel 2021) with the FILTER function, you can use the following:
Note that I used a table with structured references for the data source. This has advantages in editing the table in the future
For "pivot" header:
=TRANSPOSE(SORT(UNIQUE(Table1[Country])))
For the columns:
F2: =FILTER(Table1[[Name]:[Name]],Table1[[Country]:[Country]]=F$1)
and fill across. The results in Columns F:H will SPILL down.
If you don't have those functions, you can pivot text using Power Query, available in Windows Excel 2010+ and Microsoft 365

Related

Excel Formula to Replace Numbers List with Default Text

Using Office 365 Excel
On a regular basis I download a csv file from a remote application, the file contains a column of unique numbers. There could be 50 rows in this column.
I would like to substitute these rows of numbers with text. Each number corresponds to a value e.g.
0 = car
421 = bus
12 = boat
I have a predefined text list of each number and it's corresponding value. Currently I'm doing a find and replace on each number to replace it with it's corresponding value' but it's very inefficient.
Is there a more efficient way I can achieve this, with some sort of saved formula that I can run each time I download the csv? When I download the default csv ideally i'd like to run some formula that I have saved, rather than copy / paste a lot of things between sheets etc.
An example below of the default csv (showing only three rows for brevity);
+-----+----------------+
| id | another column |
+-----+----------------+
| 0 | text |
+-----+----------------+
| 421 | text |
+-----+----------------+
| 12 | text |
+-----+----------------+
| etc | etc |
+-----+----------------+
I would like to run a formula that will replace the numbers with text like below.
+------+----------------+
| id | another column |
+------+----------------+
| car | text |
+------+----------------+
| bus | text |
+------+----------------+
| boat | text |
+------+----------------+
| etc | etc |
+------+----------------+
Any other suggestions are also welcome, however preferred method is via Excel.
You can do it only with Excel:
create a table into a new sheet/area where you can match ids and texts that you have to replace, i.e.:
( into a new sheet named 'MyTalbe')
A |B
0 | car
421 | bus
12 | boat
...etc etc
into your db create a new colum with this formula:
index( 'MyTable'!B:B; match(A1; 'MyTable'!A:A; 0))

Cross-referencing values from a reference table with fuzzy inputs

I've got a Microsoft Access database with several tables. I've thrown 2 of those into an Excel file to simplify my work, but either an Access or Excel solution can be used for this. Below are examples of the data that needs to be manipulated, but in those records there's a lot of other columns and information.
I've got Table 1 (Input Table):
| Bank | Reference |
|-----------------|-----------|
| Chase Bank LLC | |
| JPMorgan Chase | |
| Chase | |
| Bank of America | |
| Bank of America | |
| Wells Fargo | |
The Reference column is empty. I want to fill it based on the reference table, which contains the IDs that would go into the Reference column.
Table 2 (Reference Table):
| Bank | ID |
|-----------------|-----------|
| Chase Bank | 1 |
| Bank of America | 2 |
| Wells Fargo | 3 |
So the solution would fill the "Reference" column like this:
| Bank | Reference |
|-----------------|-----------|
| Chase Bank LLC | 1 |
| JPMorgan Chase | 1 |
| Chase | 1 |
| Bank of America | 2 |
| Bank of America | 2 |
| Wells Fargo | 3 |
Since this is taken from a database's table, these aren't really ordered records. The purpose of this is to create a relationship in an already-existing database that didn't have those relationships set up.
a join between the 2 text fields, in an Update query, will provide a write of the ID for those records that exactly match.
there is no technology/option for the non matching; you can only apply some creative designs... for instance the chase bank does match for the first 10 characters... so for the non matched you could set up a temp table with a new field that is Left(fieldname,10)...join on this new field to get the ID into the temp table - - and then do a 2nd Update query to move the ID again finally using the full name

EXCEL: SUMIFS criterion applied to a INDEX MATCH search equals a value

I've spent pretty much all day trying to figure this out. I've read so many threads on here and on various other sites. This is what I'm trying to do:
I've got the total sales output. It's large and the number of items on it varies depending on the time frame it's looked at. There is a major lack in the system where I cannot get the figures by region. That information is not stored in the system. The records only store the customer's name, the product information, number of units, price, and purchase date. I want to get the total number of each item sold by region so that I can compare item popularity across regions.
There are only about 50 customers, so it is feasible for me to create a separate sheet assigning a region to the customers.
So, I have three sheets:
Sheet 1: Sales
+-----------------------------------------------------+
|Customer Name | Product | Amount | Price | Date |
-------------------------------------------------------
| Joe's Fish | RT-01 | 7 | 5.45 | 2020/5/20 |
-------------------------------------------------------
| Joe's Fish | CB-23 | 17 | 0.55 | 2020/5/20 |
-------------------------------------------------------
| Mack's Bugs | RT-01 | 4 | 4.45 | 2020/4/20 |
-------------------------------------------------------
| Joe's Fish | VX-28 | 1 | 1.20 | 2020/5/13 |
-------------------------------------------------------
| Karen's \/ | RT-01 | 9 | 3.45 | 2020/3/20 |
+-----------------------------------------------------+
Sheet 2: Regions
+----------------------+
| Customer | Region |
------------------------
| Joe's Fish | NA |
------------------------
| Mack's Bugs | NA |
------------------------
| Karen's \/ | EU |
+----------------------+
And my results are going in Sheet 3:
+----------------------+
| | NA | EU |
------------------------
| RT-01 | 11 | 9 |
+----------------------+
So looking at the data I made up for this question, I want to compare the number of RW-01's sold in North America to those sold in Europe. I can do it if I add an INDEX MATCH column to the end of the sales sheet, but I would have to do that every time I update the sales information.
Is there some way to do a SUMIFS like:
SUMIFS(Sheet1!$D:$D,Sheet1!$A:$A,INDEX(Sheet2!$B:$B,MATCH(Sheet1!#Current A#,Sheet2!$A:$A))=Sheet3!$B2,Sheet1!$B:$B,Sheet3!$A3)
?
I think it's difficult to do it with a SUMIFS because the columns you're matching have to be ranges, but you can certainly do it with a SUMPRODUCT and COUNTIFS:
=SUMPRODUCT(Sheet1!$C$2:$C$10*(Sheet1!$B$2:$B$10=$A2)*COUNTIFS(Sheet2!$A$2:$A$5,Sheet1!$A$2:$A$10,Sheet2!$B$2:$B$5,B$1))
I don't recommend using full-column references because it could be slow.
BTW I was assuming that there were no duplicates in Sheet2 for a particular combination of customer and region - if there were, you could use
=SUMPRODUCT(Sheet1!$C$2:$C$10*(Sheet1!$B$2:$B$10=$A2)*
(COUNTIFS(Sheet2!$A$2:$A$5,Sheet1!$A$2:$A$10,Sheet2!$B$2:$B$5,B$1)>0))
EDIT
It is worth using a dynamic version of the formula, though it is not elegant:
=SUM(Sheet1!$C2:INDEX(Sheet1!$C:$C,MATCH(2,1/(Sheet1!$C:$C<>"")))*(Sheet1!$B2:INDEX(Sheet1!$B:$B,MATCH(2,1/(Sheet1!$B:$B<>"")))=$A2)*
(COUNTIFS(Sheet2!$A$2:INDEX(Sheet2!$A:$A,MATCH(2,1/(Sheet2!$A:$A<>""))),Sheet1!$A2:INDEX(Sheet1!$A:$A,MATCH(2,1/(Sheet1!$A:$A<>""))),Sheet2!$B$2:INDEX(Sheet2!$B:$B,MATCH(2,1/(Sheet2!$B:$B<>""))),B$1)>0))
As you would need to make the match in memory I don't think it's feasible in Excel, you'll have to use a vba dictionary.
On the other hand, if the number of columns is fixed in your sales sheet, you can just format as table and add your index match in F.
When updating the sales data delete all lines as of line 3 and copy paste the update value. Excel will automatically apply the index match on all rows.

calculate hours between 2 timestamps using excel pivot table

i have a table like this:
user | sg_message_id | event | datetime
--------------------------------------------------------------------------------
john player | ekjf939e9313140_34k | delivered | 04/13/2018 12:56:30
john player | ekjf939e9313140_34k | opened | 04/15/2018 16:05:00
cristian dior | dsfsk0340344030fkjkj | delivered | 04/12/2018 18:45:21
cristian dior | dsfsk0340344030fkjkj | opened | 04/13/2018 15:40:17
For a user, for each unique sg_message_id, how do i create an Excel pivot table that can display hours elapsed between when an email was delivered and when it was opened?
You can use Calculated Item... in your pivot table. If your data set is not that big. Follow this steps:
You can use Power Query. It is an add-in developed by Microsoft since Excel2010+ (by default in Excel2016 known as Get and Transform). There you can connect directly any type of source of data and edit it as you want.
Here an example for your case:

How to present/organize repetitive data contained in cells in excel?

Would there be a better way to present/organize repetitive data contained in cells in excel? I've provided a set of sample data below (I can't show my actual records for confidentiality reasons) just so that you guys could visualize the data.
Country | Type | Company | Department | Project | Currency | Amount
USA | Restaurant | Bob's Barbeque | Sanitation | Monthly Sanitation | Records Database | USD | 100
USA | Restaurant | Bob's Barbeque | Human Resources | Staff Timesheet USD | 203
USA | Restaurant | Bob's Barbeque | Human Resources | Email Portal for Employees | USD | 259
USA | Manufacturing | Duff Autos | Research and Development | Inventory System| USD | 234
USA | Manufacturing | Duff Autos | Sales | Inventory System | USD | 654
China | Manufacturing | Weihua Electronics | Research and Development | Inventory System | RMB | 102
China | Government | Department of Tourism | Advertisement | Billboard Design and Deployment Web Portal | RMB | 2044
As you can see, it contains a lot of repetitive data like the "Country" and the "Type". It may look organized as it is but it looks cluttered as the data multiplies. I've thought this thoroughly over the past few days but I still can't figure out a way to do organize it such that it would look pretty.
I've tried Excel's filter functionality, sorting, and others but I still think it looks cluttered. Any suggestions? Thanks!
Pivot the data, then you can open and close the sections as you please. I just did it on your sample, then in the resulting pivot tick all the fields, drag the amount one from row labels to values then click on the little down arrow and choose value field settings.
Select Sum and press OK.
the + and - on the data in the pivot allows you to fold open and close the fields to make it look however you like.

Resources