I have the following sheet:
I then use the following formula to count the number of each type in each area/country:
=COUNTIFS($B$2:$B$19,"UK",$C$2:$C$19,"A") and I get the following result:
My problem is that I only want the same name to be counted once per area/country, therefore the value for UK / A should be 4, not 8. Does anyone know how to accomplish this?
Regards
Crouz
Concatenate your name/location columns and do your countif using that. It's not pretty, but it will do what you want.
I would do a pivot on a pivot. Both should be in classic pivot table format.
Let me walk you through the logic:
1st Pivot
Pivot your initial data. Format pivot to be classic (right click -> PivotTable Options -> Display -> Classic .. -> ok)
As Row labels have Location, Type and Name. in Values put anything you want i have chosen count of Name.
Remove subtotals, grand totals from pivot and Repeat item labels or columns Location and Type(i am assuming you have excel >= 2010). http://www.extendoffice.com/documents/excel/1964-excel-repeat-item-labels.html
2nd pivot
Pivot your 1st pivots data. Pivot to classic view. in Row Labels have Location and Type and in values whatever you want os count i have chosen count of Location. Remove sub/grand totals and repeat items and your done.
This is what i have
Another alternative is to remove the duplicates. On the data tab, click on remove duplicates. It will then all you for the criteria to use. Select all three columns. It should then work as you expect
Related
I have created a Pivot table on a dataset in Excel. I have 2 columns for yearly values and want to insert a new column in the pivot table for % change between them.
I've tried using the "Field Settings" to find percent difference, but it doesn't give the desired result.
This assumes you don't have gaps between years.
Add the amount field to the values section of the pivot table, so that it is there twice.
Right-Click one of the values in the newly added
Choose Show Values As -> % Of ... ->
Base Field should be: Year and Base Item should be: (previous)
Rename column to % Difference
It will show for every year, so hide the column for years that you don't want it
Not too hard, when you have your pivot table:
Select any cell
Go to Excel Ribbon > PivotTable Analyse > Fields, Items & Sets > Calculated Field
Give a title, e.g.: % Difference and add a formula:
= ('2018-19'-'2017-18' )/'2017-18'
Confirm and once confirmed, change the datatype of this field to percentage
Note, things might be named a little different in your Excel since I'm using a Dutch Excel 2019 version.
Anybody has an idea why i cant use pivot table count value that is a number for a calculated field in that same pivot table?
Here is the picture of what i mean:
Count field in the pivot table counts how many of the certain Models are in a table and i would need to use the following formula: Count divided by Sum of IN in this pivot table.
Every time i try to use the value from "Count" column it returns the #VALUE.
It might be a formatting issue where excel is not understanding that one of the numbers is a number. There are a couple of ways to address the issue.
Highlight the cells, Home>Number, then apply the number format.
Select the pivot table,
in the pivot table fields box, select the dropdown arrow in the values section and select Value Field Settings
Then select Number Format and then choose the desired formatting (likely Number)
Force it as a value in your formula.
I assume your formula looks something like
=D4/C4 or
=GETPIVOTDATA("Sum of Sum",$A$3,"Top","Top","Name","Bottom
")/GETPIVOTDATA("Count of Count",$A$3,"Top","Top","Name","Bottom ")
you can use the VALUE() function to create
=VALUE(D4)/VALUE(C4) or
=VALUE(GETPIVOTDATA("Sum of Sum",$A$3,"Top","Top","Name","Bottom
"))/VALUE(GETPIVOTDATA("Count of
Count",$A$3,"Top","Top","Name","Bottom "))
Create a new 'Calculated Field' in your pivot table that does the function for you.
Select the pivot table, then Analyze>Calculations>Fields Items & Sets>Calculated Field
Give your field a name, then for your formula, enter something along the lines of Count/Sum of IN. Use the Fields box to make sure you get the Field names right
Hopefully one of these options will help you get what you need.
I would like to present some data in Excel in a table. I have a sheet with three columns: date, time_spent and user_id. Every row is a data record. I want a table with a column for every date and every value with time spent below the date.
Using the transpose function under paste special I get this:
However I would like only one column per unique date, so the amount of columns decrease like this:
Does someone know how to do this?\
I have more than 10000 rows, so manually is too much effort...
Using Pivot Tables as Tim Biegeleisen suggested I cannot get what I want either, I'm not an expierenced user of Pivot Tables so probably I'm doing something wrong:
Excel file as shown in above picture
Here is one way of using a Pivot Table as suggested by Tim above in the comments, but you must use it on your original, non-transposed data: (and note which parameters go to which areas.
A disadvantage of the Pivot table is that the column headers are text strings and not dates. If your version of Excel is 2010+, you can use Power Pivot or Get and Transform to do a better job:
Open the Query Editor, change the format of the Date column, and Pivot the column:
Then Save the results:
Advanced filter dates to unique values in a new column
Copy and transpose them to make your column titles
Insert a new column B with the formula =TEXT(A2,"yyyyddmmm")&COUNTIF($A$2:A2,A2) and fill down
Below your new column headers put in the formula =IFERROR(VLOOKUP(TEXT(H$1,"yyyyddmmm")&ROW()-1,$B$2:$C$8,2,FALSE),"") and fill down and across. You will need to fill it down to cover the maximum number of instances of each date.
Adding a sumif to this table and your initial table would be a good way to check you got everything.
My current pivot table contains 4 columns: time in Column A, then Zone 1 in Column B, Zone 2 in Column C, and Zone 3 in Column D.
Is there any way to "lock" the columns, e.g. if I apply filter by Zone and only select Zone 3, Zone 3 will stay in Column D?
Currently, if I filter by Zone and only select Zone 3, Zone 1 and Zone 2's column disappear and Zone 3 will then be in Column B.
Thanks for any help you can provide.
I'm going to say "No". Pivot tables are a world to themselves inside of Excel.
You may have noticed that if you do something that expands them into surrounding data, they don't shift that data, they just warn you. Similarly, if you have formulas that refer to certain columns in a pivot table, filtering the pivot table as you've done doesn't adjust the cell reference as it does when you add or delete regular columns. I assume this is the type of issue you're seeing.
If so, consider using the GetPivotData function, which allows you to refer to pivot table columns.
Below I've shown how this could work with a simple table. The GetPivotData formula uses a variable (an added bonus!) in cell F1. In this case it gives you the overall total for fiona:
=GETPIVOTDATA("value",$E$4,"name",F1)
Note that when I filter to just "fiona" it still works:
Note that you can make the formula as specific as the data in the pivot table. Here I get the sales for doug on Thursday. (I could use variables for both "doug" and "Thursday" here as well:
=GETPIVOTDATA("value",$E$4,"day","Thursday","name","doug")
The easiest way to create a GetPivotData formula is to type "=" in a cell and then click in the pivot table cell you are interested in. You can then edit from there.
Here's a great Contextures GetPivotData tutorial.
Yes, here is how:
1-Go to the column values you want to prevent from collapsing.
E.g.: Field Settings menu
2-On Field Settings, select the 'Layout & Print' tab, then check the 'Show Items with No Data' checkbox.
E.g.: Show Items with No Data option
This should prevent, say, your column D data from moving to the spreadsheet column A data whenever the columns to the left of D do not have any value for the filter/slicer settings.
I was wondering if it's possible to filter a single pivot table column in excel.
In other words, when you summarize the data by count, that the data for a certain column is only counted if it has a certain value.
I know that it's possible to get these values by report filtering, but then I need a separate pivot table for the values I don't want to be filtered. Also, some values are 0 and thus are not displayed if report-filtered. Changing the option to display 0 values doesn't change anything. Thanks in advance.
Yes, you can add a filter to a pivot report by selecting a cell that borders the table (but is outside the pivot area) and choosing Filter from the Data tab.
To add a filter to just the Count Of column select the cell above and the cell containing the title and then choose the Filter option from the menus as shown...
To only count data if it fulfills a certain condition, I think you would need to add another column called OK to the source data, with a formula like IF(Status="OK",1,0). Then add this to the pivot table layout. [Note: there is a calculated field option for pivot tables but it only seems to work as you would expect if data is displayed - in this case status would need to be showing.]
That's not working on my Excel 365. Try selecting the 1st field on the first row then:
r-click
filter
value filters...
Left click on any row items drop-down carrot
Click 'value filter'
Choose value filter ('equals', 'greater than', etc)
Choose value field item you'd like it to filter on (eg 'count of days' from the image i can see in the original question)
You can also do it via the right click options as #kztd mentioned