I have a workbook with multiple sheets. On sheet1 I would like to count the number of times person in column A has a particular entry in Column C that meets criteria of column D = Content but only count if column B is a unique value.
Using the below formula I can do everything except only counting unique numbers in Column B. I enter this formula in Sheet2 C2 then pull across to I2 then pull down to 6 in each column.
=IF(COUNTIFS(Sheet1!$A$2:$A$150,Sheet2!$B2,Sheet1!$C$2:$C$150,Sheet2!C$1,Sheet1!$D$2:$D$150,"Content")=0,"",COUNTIFS(Sheet1!$A$2:$A$150,Sheet2!$B2,Sheet1!$C$2:$C$150,Sheet2!C$1,Sheet1!$D$2:$D$150,"Content"))
I am using the double countifs to not show 0's.
Here is what it looks like for Sheet1
Here is how I would like Sheet 2 to look
Any help or advise would be much appreciated.
The answer by Vijayakumar works. In case you need a simpler version (without the data model option, use this formula in column E dragged down
=SUMPRODUCT(--($B$1:B1=B2))>0
Select all data
Insert ->Pivot table
In The Pivot table fields Move "SR" to Rows section "Stage" to column section "Prod" & "IsUnique" (Col E) to filter section and "QN" to Value section
Now right click on some cell in Pivot which shows sum/count of QN Summarize
values by -> Count
In the filter section of pivot (first row on
pivot table which states "Prod"), choose "Content"
In the filter section of pivot (Second row on
pivot table which states "IsUnique"), choose "TRUE"
When you have new data, you just need to Change Data Source from the Pivot Table tools->Analyze or Refresh. However you can record this whole process as macro to automate it.
You can achieve this via Pivot table.
Select all data
Insert ->Pivot table
In the pop up ensure you check the check box at the bottom with description "Add this data to data Model" and then click OK. This will create Sheet 2 for you.
In The Pivot table fields Move
"SR" to Rows section
"Stage" to column section
"Prod" to filter section
"QN" to Value section
Now right click on some cell in Pivot which shows sum/count of QN
Summarize values by -> More optins
In the pop up, scroll to bottom and click on "Distinct Count"
In the filter section of pivot (first row on pivot table which states "Prod"), choose "Content"
Note: Distinct count won't appear in values section if step 3 is missed out. Hope this helps.
Related
Can you help me to solve this problem?
I have two row with different value each row like this:
I want to count how many city with name london but only count if the Name if different, so from the table above the result count is only 2 london.
You can use a pivot table as a step to help:
Select the data and set up the pivot table:
Change the design of the table to set:
a. Report layout to tabular form
b. Report layout to repeat all item labels
c. Subtotals - do not show them
then the pivot table should be like this:
Finally, you can use COUNTIF. In my example, I have put the city name in G2 and referencing it in the formula:
=COUNTIF(D:D,G2)
You first need to group both columns
=COUNTIF(UNIQUE(A2:B14),"london")
COUNTIF count cells based on one criteria
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.
I worksheet containing following data (sheet name _ BDAY)
A Column : Date B Column Name C Column Year
All the data in column is assorted manner
I want this to be sorted out in another sheet name (Current Bday)
the sorting should be as per the Month & date wise. The Current Bday sheet shold be auto sort as I enter new row in BDAY sheet. I have got around 950 rows in Bday sheet & much more to enter.
user3705748.
I hope it helps.
First of all, I would add an additional column to your first sheet (_BDAY), so that it looks like this:
DATE (Column A) | MONTH (Column B) | NAME (Column C) | AGE (Column D)
In column B, you will use the formula =MONTH(), making a reference to column A (date). This way you will get the month for each date. The new layout should look like this:
Second step: add a pivot table. Select range "A:D" in sheet _BDAY, and insert the pivot table in sheet Current Bday.
Third. Add row fields like this:
Your pivot table will look like this:
Now, let's change the look of the pivot (step four). Right click on the pivot and click on Pivot Table Options...
Go to Display and click on checkbox "Classic pivot table...."
Remove subtotals per month, date and name:
This is how your final pivot should look like:
As you enter new items in sheet _BDAY, just refresh the pivot in order to drag them into the pivot (right click on the pivot):
Go to any position in the month column inside the pivot and sort as you prefer. It also works with other fields (date, name, age).
Please let me know if it was helpful.
I am using Excel 2013 and I have a PowerPivot which refreshes the data from an SQL database.
I have designed a pivot table from the data but I am getting really frustrated at one aspect of the design. I have dragged a field named "Room Category" in the ROW field, dragged a specific field in the VALUE field. I have then added another field as a Slicer, which is basically acting like a filter. I have re-arranged the "Room Category" field on my pivot table manually. However, each time I click on a different item in the Slicer and come back to the original item on the slicer, the order of the "Room Category" is set back to the default alphabetical sorting order!!
I have been looking for a solution all over the web but to no avail!
I am adding below an extract of the data that is being used to create the pivot table:
Property RoomCat Order
A2 X 2
A2 Y 1
A2 Z 3
B5 C 1
B5 D 4
B5 E 2
B5 F 3
So when I've created my pivot table, I have Property as a Slicer and I have manually re-arranged the RoomCat to show as follows for Property A2: Y,X and Z. I've done the same for Property B5 to show as follows: C,E,F,D
However, when I click on Property B5 on the Slicer and the click back on Property A2 on the slicer, the RoomCat for Property A2 now shows up as: X,Y and Z
The PivotTable will always sort alphabetically unless you give it something else to sort by. If you add a new field to your data which contains the sort order, then you can tell PowerPivot to use that as the sort order.
First Select your Room Category column, click on the Sort By Column button, then select the column that contains your sort order:
And the result:
I think I understand the issue (I've had the same problem with Dates as Text). I think if you create a "Named Set" based on the row Items, it will work.
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.