Distinct rows on Pivot Table - excel

I'm trying to display data with a pivot table with a distinct of rows
Data
Id | Date | Count | Date 2 | ...
1 | 21/02/2020 | 1 | | ...
1 | 21/02/2020 | 1 | 21/02/2020 | ...
2 | 15/05/2021 | 0 | 15/05/2021 | ...
3 | 17/09/2020 | 2 | 17/09/2020 | ...
3 | 17/09/2020 | 2 | 19/10/2021 | ...
3 | 17/09/2020 | 2 | 25/11/2021 | ...
Expected result in the Pivot Table
Id | Date | Count
1 | 21/02/2020 | 1
2 | 15/05/2021 | 0
3 | 17/09/2020 | 2
Can you please explain me quickly how to setup the Pivot Table to get this result ?
Indeed, I'm getting 2 for id 1 and 6 for id 3 ... SUM is performed (instead of 1 and 2).
Moreover, I'm not able to put the value of the Date as a column ...
Maybe that Pivot Table is not the correct way to do it.
I hope it is clear ...
Many thanks in advance

Just adding the answer per the comment..
To achieve your Expected result, you can use a pivot table where you put those 3 fields in your "rows" value. Then change your design to Tabular mode, do not show Grand or Sub totals.
You could also simply copy those 3 columns, and paste elsewhere, then with all 3 columns highlighted do to Data and remove duplicates.

Related

excel pivot table with unique data so don't weant to see the count but the actual data

I have a csv file like this
| Date | PO |
|21-04-21| A |
|21-04-21| B |
|21-04-21| C |
|22-04-21| B |
|22-04-21| C |
|23-04-21| B |
|23-04-21| D |
atm, when I'm making a pivot table in excel, I'm getting the count number
|21-04-21|22-04-21|23-04-21|
A | 1 | 0 | 0 |
B | 1 | 1 | 1 |
C | 1 | 1 | 0 |
D | 0 | 0 | 1 |
I'd like formatted this way since each row are unique:
|21-04-21|22-04-21|23-04-21|
| A | B | B |
| B | C | D |
| C | | |
Is it possible using a pivot table or I need another way to do so...
thks gorgeous people!!
You can add a measure to show the information.
Make a table and create pivot from the table.
Choose "Add this data to the Data Model". The table will be named Table1
Create a new measure for the pivot table.
Then enter the following DAX formula:
=CALCULATE(CONCATENATEX(VALUES(Table1[PO]),Table1[PO]," "))
Then enter move the field as the picture:

Sum of max in Excel Pivot Table

Please do not mark this as duplicated of Sum of Max in PivotTable for Excel because there is no even answer for it.
I have a pivot table of items grouped by ID and month, and getting the maximum Q among all items. So the totals get the maximums as well.
+------------+---------+----------------+
| A | B | C |
+-+------------+---------+----------------+
|1| Month | ID | Max(Q) |
+-+------------+---------+----------------+
|2| 1 | A | 23 |
+-+------------+---------+----------------+
|3| 1 | B | 11 |
+-+------------+---------+----------------+
|4| Subtotal 1 | 23 |
+-+------------+---------+----------------+
|5| 2 | C | 85 |
+-+------------+---------+----------------+
|6| 2 | D | 6 |
+-+------------+---------+----------------+
|7| Subtotal 2 | 85 |
+-+------------+--------------------------+
|8| Total 85 |
+-+---------------------------------------+
What I want to do is still get the max of each ID, but the totals to be the sum of the maximums. Like the following.
+------------+---------+----------------+
| A | B | C |
+-+------------+---------+----------------+
|1| Month | ID | Sum(Max(Q)) |
+-+------------+---------+----------------+
|2| 1 | A | 23 |
+-+------------+---------+----------------+
|3| 1 | B | 11 |
+-+------------+---------+----------------+
|4| Subtotal 1 | 34 |
+-+------------+---------+----------------+
|5| 2 | C | 85 |
+-+------------+---------+----------------+
|6| 2 | D | 6 |
+-+------------+---------+----------------+
|7| Subtotal 2 | 91 |
+-+------------+--------------------------+
|8| Total 125 |
+-+---------------------------------------+
I can't do the trick of this video https://www.youtube.com/watch?v=URfAkq0_dj0 because:
I can't alter the DB.
The origin table is in the data model so I think it's the reason why I'm not able to select a custom subtotal (Not sure, correct me if I'm wrong).
Any ideas?
Oh, also I'm open to use VBA.
You can't do it in pivot. But if you can add helper column to source table, you can use following array formula to calculate MAX value in group and then use this column in pivot:
{=IF(SUM((A2=$A$2:$A2)*(B2=$B$2:$B2))=1;MAX((A2=$A$2:$A$15)*(B2=$B$2:$B$15)*($C$2:$C$15));0)}
Change semicolons to commas if needed.
Array formula after editing is confirmed by pressing ctrl + shift + enter
Assuming your pivottable looks something like this:
You can right click the subtotal line, go to "Summarize Values By" and select "Sum":
Which results in:

Lookup between two tables on a unique ID AND where the date is between two other dates

I have two tables in Excel. One has Key and Date - this can be table A. The other has Key, Begin Date, End Date, and Value - let's call this table B.
I am trying to pull into Table A the Value from Table B for the Key , where the Date from Table A is between the Begin Date and End Date from Table B. The value should be 0.4 using the example tables below.
NOTE: There will never be overlapping dates and shouldn't have multiple rows for the same date range.
Table A -
| Key | Date |
|-----|------------|
| 2 | 10/29/2018 |
Table B -
| Key | Begin Date | End Date | Value |
|-----|------------|------------|-------|
| 1 | 07/01/2018 | 12/31/2999 | 0.1 |
| 1 | 01/01/1995 | 06/30/2018 | 1 |
| 1 | 01/01/1900 | 12/31/1994 | 0.5 |
| 2 | 10/31/2018 | 12/31/2999 | 3.6 |
| 2 | 01/01/1995 | 10/30/2018 | 0.4 |
| 2 | 01/01/1900 | 12/31/1994 | 10 |
| 3 | 01/01/1900 | 12/31/2999 | 100 |
Thanks!
Assuming there'll only be one match, use SUMIFS.
=SUMIFS($I$1:$I$8,$F$1:$F$8,A2,$G$1:$G$8,"<="&B2,$H$1:$H$8,">="&B2)
Note - changed two instances of 12/31/1995 in Table B to 12/31/1994, assuming that it's a typo and date ranges shouldn't overlap between rows.
EDIT:
You can use INDEX and AGGREGATE if you need to return text.
=INDEX(I2:I8,AGGREGATE(15,6,ROW($A$1:$A$7)/(($F$2:$F$8=A2)*($G$2:$G$8<=B2)*($H$2:$H$8>=B2)),1))

Getting Summation from a Table, with matching values from another Table in Excel

I have 2 tables created in Excel, which are identical in structure and the column and row names.
The only difference is that the first table has data (for the effort in work days) in it while the second is a reference table stating which milestone each cell belongs to. A sample of these tables is:
TBL1:
| | App1 | App2 | App3 |
| T1 | 32 | 12 | 48 |
| T2 | 40 | 16 | 30 |
| T3 | 56 | 18 | 36 |
TBL2:
| | App1 | App2 | App3 |
| T1 | 1 | 2 | 3 |
| T2 | 2 | 1 | 2 |
| T3 | 1 | 1 | 1 |
I want to collate these values so that I get SUM of 1, 2 and 3
| | Days Summation |
| 1 | =32+56+16+18+36 |
| 2 | =40+12+30 |
| 3 | =48 |
So basically, want to find:
IF(COL_VAL_IN_TBL2=1) THEN SUM ALL VALUES IN TBL1 CORRESPONDING TO THE ROW-COL IN RESPECTIVE
Is it possible to get a formula which I can use to do this without using something like a Pivot Table?
You can use sumif() to do this:
Here it's just looking at table2 values and comparing them to your 1, 2, or 3 and then summing the corresponding cells from your table1
SUMIF will do the trick if I understand correctly:
If you put 1 in A1, then 2 in A2, etc. Then enter in B1=SUMIF(TBL2Range,A1,TBL1Range) and copy down. Where TBL2Range is the address of your table.

Can I populate a column with conditional data while omitting empty rows or possibly autosort?

In one spreadsheet document, file.xlsx, I have 2 sheets. Sheet1 has the editable fields. Sheet 2's sole purpose is to read the data from Sheet1.
The point is to keep track of inventory and easily display items needed to be ordered.
Sheet1 'column a' is item number for ordering
Sheet1 'column b' is the number I have on hand
Sheet1 'column c' is the formula cell to find the number needed to be ordered
It looks something like this:
Document1:sheet1
A | B | C |
1 |txt1 | 1 | =10-b1 |
2 |txt2 | 0 | =10-b2 |
3 |txt3 | 13 | =10-b3 |
4 |txt4 | 5 | =10-b3 |
5 |txt5 | 2 | =10-b4 |
There is some if statement conditional formatting in the "C" column to check if the "B" column has a value HIGHER than 10 and if it hits true then the corresponding C cell is blank but for space, i'm summarizing here
Document1:sheet2
A | B |
1 |=if(sheet1!C1>0,Sheet1!A1,"") |=if(sheet1!C1>0,Sheet1!C1,"") |
2 |=if(sheet1!C2>0,Sheet1!A2,"") |=if(sheet1!C1>0,Sheet1!C2,"") |
3 |=if(sheet1!C3>0,Sheet1!A3,"") |=if(sheet1!C1>0,Sheet1!C3,"") |
4 |=if(sheet1!C4>0,Sheet1!A4,"") |=if(sheet1!C1>0,Sheet1!C4,"") |
5 |=if(sheet1!C5>0,Sheet1!A5,"") |=if(sheet1!C1>0,Sheet1!C5,"") |
If an item isn't to be ordered because stock is high, it doesn't show up in the list. This is ok. It looks like this:
Document1:sheet2
A | B |
1 | txt1 | 9 |
2 | txt2 | 10 |
3 | | |
4 | txt4 | 9 |
5 | | |
What I would like to see is:
Document1:sheet2
A | B |
1 | txt1 | 9 |
2 | txt2 | 10 |
3 | txt4 | 9 |
4 | | |
5 | | |
For 5 Items in the example, it doesn't seem that annoying, but in actuality I have 1200 potential rows and it varies between 200 to 800 actually populated each time i conduct inventory. The whole point is to have one continuous section of rows that I can select and print. Maybe some way of autosorting and placing the empty ones on the bottom?
I've taught myself excel. I don't know the advanced tricks and things.
I'm a typically a programmer but I've been tasked with this project and the guys upstairs want me to do it in excel.
i've overcomplicated this, to the max.
a simple sort putting the empty's at the bottom is the resolution.
not quite as automated as i'd like
but
it works.

Resources