Custom column in Excel pivot table - excel

I am using a pivot table to display data. In the pivot table I have countries and under each country couple of names. Then how many training a person led and how big attendance there was.
I have two questions:
1) In the data source, I created additional column where is displayed the last training date (latest date) for every person. Meaning that in the source data, in every row for one person, there is always the same "Last training date". I would like to take this information a show it in the pivot table. But anywhere I put it, it's always used as another filter and it makes the table much more complex. I would like to have just a custom column with this info without having to expand the whole table. It's the last column in the example image.
2) Same applies for the attendance. If the training has been cancelled, the attendance is always 0. Is there a way to hide the whole column? Same for the total of attendance. I don't really need these columns.

Try This:
First question:
In the main table change the [Date Field] to type Number
Put the [Data Field] in values into the pivot table
Select any value where is the column [Date Field] and right click:
Go to Summarize values by select Max
Again right click. Go to Number Format...
Select the date format what you like
Second question:
I would like to see a data's sample. It could be fake. I have some ideas but is difficult to see just guessing...

Related

Create calculated column in one table using data from another table in Spotfire?

Apologies for asking this, I see a few similar questions but unfortunately I don't really understand the answers given. I am fairly new to Spotfire.
I am trying to create a calculated column in one table based off of data from another table. The first table (which I am trying to add the new column to) is a monthly data census of all contracts the company has. Each contract has one row. Call it "monthly table". The second table is a complete transaction history for all contracts, so each contract can have hundreds of rows. Call it "total table".
I am not sure if I can link the data tables. I read in a few similar questions to insert columns from the table with data into the table where the new column will go, or to merge them beforehand, but the monthly table has about 13,000 rows compared to the total table's 550,000, so I am not sure how this would work.
I am trying to create a column to sum all the transaction amounts for each contract if the transaction type (also in the total table) is equal to a certain string. Like a "net transactions to date" column. I successfully created this column in the total table, but then each cell for a contract that meets the conditions had the transaction sum. I want it in the monthly table, where each contract just has one row, and it only displays the sum once. This is the code I have:
IF(
Concatenate([Contract_Number],"(transaction type string)",[Month],Year([Date]))
=[Type],
Sum([Amount]),
NULL)
It is currently in the total table. If possible I would like it in the monthly table, and for the [Number] and [Date] columns to refer to the monthly table, and [Type] and [Amount] to the total table.
Sorry if this is too much information or confusing! Also I know there is a problem with my summation (it is summing all transactions and only displaying in the correct rows, but it needs to only sum correct rows), but I think I can figure that one out, I just need help getting it in the right table.
I am currently working on transitioning a process/workbook from Excel to Spotfire.
If it would help I can provide the current formula used for this process in Excel.
After a few more hours of tinkering, I figured it out! I thought I would explain what I did here in case anyone else encounters a similar conundrum.
TLDR; Made the desired column in the total table, and added the new column to the monthly table with a left single join on the contract number.
My month and date are tied to a document property which is a drop-down of unique date values in my monthly table. Within the total table, I used a similar code to what I've typed above, but instead of referencing the Date column directly, I referenced the document property, so it was pulling the date from the monthly table into the total table. I also switched from the form IF(condition, SUM()) to SUM(IF()) OVER (). This ultimately summed the correct values. For example, there might be five different types of transactions for each contract, but I only wanted the sum of two types. This resulted in the correct sum being displayed. The sum was displayed in every single cell corresponding to the correct contract number in the new column, so (in the same example) in all 5 contract #1 rows, the sum of the two correct types was displayed.
Then, I went to the data canvas for my monthly table, and added the new column. I chose a left single join, as each contract had only one row in the new table, so that the correct sum would only be displayed once.
End result code:
SUM(IF(Concatenate([Contract_Number],"type-string",[Month_ValDt],[Year_ValDt]) =
[Type], [Amount],0)) OVER ([Contract_Number])
Where [Month_ValDt] and [Year_ValDt] are new columns I made in the total table that display the month and ye
ar from the document property that is tied to the date in the monthly table.
Reasoning for the property is that we have a few years of data but I was told to make it dynamic so only one month of data is visible at a time, hence the drop-down.

Excel Pivot - spanning field name across all relevant columns

I have a table of employees with their work location (state initials) and their work status (FMLA leave, part time, full time). I've made a pivot table so that I can see the number of employees in each state relative to their status. Making the pivot table is easy, and it looks like this:
My question relates to the column field name cell (highlighted in red). When the table is first created, Excel auto fits the columns. However, if you look at the picture, it is clear that ideally the FMLA, FT, and PT, columns should all be the same size for the table to look good. I can resize the columns, of course, and set the table to not auto size when it refreshes.
When I resize the columns the table now looks like this:
Two problems with the new layout. First, it is not clear at all that the "Employee Status" field name applies to all three columns FMLA, FT, PT. Second, with the first column being narrower "Employee Status" no longer fits. In Excel 2013, the field name is limited to just its column. In Excel 2016 it spills over to the next column, but has the filter pulldown in the middle of it! And of course the formatting doesn't spill over.
In a non-pivot, I would "merge" the three cells above the column headings and make "Employee Status" span all three cells. Leading to a much more intuitive look. However, "merge" cannot be used in pivot tables. My only work around at the moment is to Hide the row with the field name, and put a new row above it that is not part of the pivot table. Ends up looking good, but of course, it will not dynamically adjust if a new value is added to "Employee Status".
I'm looking for other recommendations on how to format this table so it ends up looking like this:
Ideally solution will work with Excel 2013, which unfortunately is what I'm limited to.

Calculate average of values in a column based on matches of two variables in two other columns

I'm having an issue with some data that I'm working on that has had me stuck for a while.
I'm working on some patient data for a clinical practice that has each patient encounter logged on a separate line with an account ID, date of service, the height and weight measurements for that date, and other variables.
Aside from VLOOKUP and the usual formulae/functions I've got a pretty rudimentary understanding of Excel but I can pick up on things fairly quickly.
In the data I've got each line tied to a patient account ID as well as what quarter the DOS was in. For patients with multiple visits, they will be identifiable by repetitions of the account ID number on other lines.
For some patients, there will also be repetitions in the quarter if the same patient was seen twice in the same quarter. This is where I need help.
I'd simply like to average the value of a variable for each patient in each quarter. I'm not sure if AVERAGEIFS is the right function to use but I need an operation that checks for matches in a line of both account ID and quarter (Q1, Q2, Q3, or Q4) with the other lines in the sheet and comes up with a quarterly average for the variables in question.
What I have
What I need
If I'm understanding your question, you could use AVERAGEIFS to accomplish what you are asking. With excel, a lot of how successful an approach will be is determined by how your data is structured, and if/how often you are planning on updating your work.
It would be easier to give a concrete answer with an example of the data you are looking at.
If your source data is in columns A:D something like:
and you are looking to summarize the weight data in I by account ID and Quarter:
you could use AVERAGEIFS(C:C,A:A,G2,B:B,H2) this would find the cells in column A that match the value in G2, find the cells in column B that match the value in H2, and report the mean value in column C of the matching rows.
An alternative is to use a pivot table, which automates a lot of what you are trying to do. For that approach you would select your data block, and click on Insert>>Insert Pivot Table (at least in my version). That should bring up a wizard. Accepting the defaults will create a new sheet. Then look on the right side of your window, and you should see a list of your column names near the top, and four boxes called Filters, Columns, Rows, and Values. You should be able to drag and drop your columns into these boxes to get summaries of your data. If you add your Account ID and Quarter tabs as columns, and your height and weight as Values, then right click on each of the value columns and select "Value Field Settings" and select Average from the menu that pops up. That should give you something that looks like:
At that point, you can change the formatting to make if fit your needs, or copy data somewhere else.
The AVERAGEIFS approach will automatically update if you add more data, but will only summarize things that match the values you list. If there is an account ID/Quarter pair that isn't in the summary column you won't have any idea it's there. If you are summarizing an ID/Quarter pair that isn't in your data you'll end up with a division by Zero error like in the example.
The Pivot Table option only updates when you manually click refresh (right click and choose refresh pivot table from the menu), but will summarize all the data based on the columns you've selected. It's also a little more robust as you avoid having to type out the formulas and make sure you are pointing to the right column. This option also by default provides nested summaries; you can turn the subtotals and grand totals off if you want.
I used the function:
=SUMPRODUCT(($B$2:$B$13="Customer 1")*($C$2:$C$13="Q1"))
Where Customer 1 could be a user id and Q1 you can change to which quarter you want.
Excel screenshot

Restructuring data in excel

I am trying to condense data in a specific way. I want any occurrences of the number 1 in each column to show up as 1 (regardless of how many times it occurs) with the corresponding site, in the corresponding column. Some sites occur multiple times in the original data, and I want to make it so that only one of each unique site shows up in the resulting data table with a 1 for the corresponding column if there any 1's in the column from the original data.
I would think it would be a vlookup function, but I have tried many different things and I am really stuck on this.
Image of original data and what I am trying to do:
Thank you
This assumes that your data set only contains 1 or blank and this approach uses a Pivot Table with MAX function. Below are details in case anyone doesn't know Pivot Tables.
Select a cell in your data and insert Pivot Table. Note, I added a title for column A, as you need that in the Pivot Table.
Click in the created Pivot Table and the PivotTable Fields dialog should pop up. If not, right click in Pivot Table and select Show Field List.
Drag the Field names (Code, a, b,& c) down to the appropriate blocks below. (Values under Columns will be created for you.)
Click on the drop down arrow next to each field name and select Max. That will rename it to "Max of ...". If that bothers you, then you can type the name you want into the Custom Name field. Note, it will not let you type the same name as the field name, eg a, but it will work if you put a space in front of it.
Given that the Pivot Table would be a lot of work for a large number of columns, here is a formula based approach. Put this formula in cell G2, then drag it down and across to fill your new table.
Note, you will have to populate all codes that you have in column F. And if any new codes are added later you will have to keep this updated. One of the advantages of a Pivot Table is that it will do this for you.
I know that you won't be putting this in these cells, so adjust accordingly. In fact, I would recommend this be in another sheet.
=IF(COUNTIFS($A:$A,$F2,B:B,1)>0,1,0)
COUNTIFS($A:$A,$F2,B:B,1)
This will count each occurrence when the value in column A matches your code $F2 AND the value in column B equals 1.
If that count is >0, then you know that at least one match was found and the IF will return 1, otherwise 0.

Excel 2010 Pivot Table - Convert Text into Data

I have 2 worksheets that I need to create 2 different pivot tables for.
On the first worksheet (Injuries) I need the data to be sorted by Department (FSD or Dist), which is marked by placing an "X" in the correct category.
I then need columns that quantify which type of injury it was, for example "Record Only", "Lost Time", etc. and know how many lost days there are for each department.
I'm stumped on how to change the marked categories into actual numerical data in the table.
On the second table, "Motor Vehicle Accidents", I again need the data sorted between department, which is marked with an "X".
I then need to know which type of accident it was, for example "Preventable" or "Parked".
Make a Column that maps that for you. For example, for the first Sheet, you can make a column and put the following formula on the cell:
=IF(D46<>"";"FSD";"DST")
For the second, it will be the same principle:
=IF(G85<>"";"PREVENTABLE";IF(H85<>"";"NON PREVENTABLE;IF(I85<>"";"PARKED";"1-800 MOR")))
Hope it helps.

Resources