Trying to automate the numbering of Excel rows, but only semi sequentially, based on conditions - excel-formula

I'm trying to get a system set up on a data compilation sheet in excel. Going in and adding all the new information, and then deleting the old information has become extraordinarily tedious. I'll type out what I'm trying to accomplish, as an example.
A
B
C
Name
Date
Desired AutoNumber
Item 1
01/17/23
1
Item 1
01/17/23
1
Item 1
01/17/23
1
Item 1
01/06/23
2
Item 1
01/02/23
3
Item 1
01/02/23
3
Item 2
01/17/23
1
Item 2
12/24/22
2
Item 2
12/16/22
3
Item 2
11/18/22
4
Item 3
01/16/23
1
Item 3
01/16/23
1
Item 3
01/13/23
2
Item 3
01/11/22
3
Item 3
01/08/23
4
Item 3
12/26/22
5
Item 3
12/26/22
5
Wanting to use this format, as the most recent 5-7 dates per item are needed to remain. (This is for an online games' external assistant system)
What I've found either only numbers the rows based on item name, or based on the dates per item name, which isn't what I'm trying to make happen. What I've used so far is:
=countif($A$2:A2,A2) (which numbers based on item name) or
=countifs($A$2:A2,A2, $C$2:C2, C2) (which numbers based on the dates per item name, which is closer to what I'm looking for, but not in the right format)
By also adding in offset, it does the same thing.
=countif(offset($A$2:A2,0,0),A2)
I'm not sure if there's even a way to number it the way I'm looking to, since it's not numbering within a specified date parameter. I've been trying to do this without using a macro, since the information is going into a larger database, and certain information can't be deleted. Is there a way to do this using a formula?

Related

Dynamically sort list based off associated values with tie-breaker values

I'm trying to sort students based off frequency of participation. I have a table that is automatically generated totaling up how often a student has participated in the last few days.
I want it to do 2 things that I can't figure out.
I want it to ignore students that are at 0 removing them from the resulting rankings.
The first number is most important but I want it to reference the next value in the result of a tie.
Short example of table:
Andy - 1 1 2 3
Brad - 0 1 2 3
Cade - 1 2 3 4
Dane - 1 1 1 2
Desired result:
Cade - 1
Andy - 1
Dane - 1
The tie-breaker isn't that important and I figure I can have conditional formatting to remove children at 0, but I still can't seem to figure it out.
The closest formulas I have found in my searching are:
=INDEX($A$10:$A$9,MATCH(ROWS($C$1:C1),$C$1:$C$9,0))
This one doesn't work because it returns #N/A for pretty much all students who are tied.
=IFERROR(INDEX($C$1:$C$9,MATCH(SMALL(NOT($C$1:$C$9="")*IF(ISNUMBER($C$1:$C$9),COUNTIF($C$1:$C$9,"<="&$C$1:$C$9),COUNTIF($C$1:$C$9,"<="&$C$1:$C$9)+SUM(--ISNUMBER($C$1:$C$9))),ROWS($C$1:C1)+SUM(--ISBLANK($C$1:$C$9))),NOT($C$1:$C$9="")*IF(ISNUMBER($C$1:$C$9),COUNTIF($C$1:$C$9,"<="&$C$1:$C$9),COUNTIF($C$1:$C$9,"<="&$C$1:$C$9)+SUM(--ISNUMBER($C$1:$C$9))),0)),"")
I had this formula that can handle ties but it needs to be OFFSET but I don't know how since it is an array formula. Also, with both these formulas it reverses the ranks with the lowest values at the top. If anyone could assist me I would greatly appreciate it. I'm doing this so that I can give all students a chance to participate equally.
Use a helper column. In that column put the following formula:
=IF(B1=0,"n/a",SUMPRODUCT(B1:E1/10^(COLUMN(B1:E1)-MIN(COLUMN(B1:E1)))))
This will return a single number based on the rankings.
Then in your output column use:
=IFERROR(INDEX(A:A,MATCH(LARGE(F:F,ROW(1:1)),F:F,0)),"")
Then a simple VLOOKUP to return the first number:
=IF(I1<>"",VLOOKUP(I1,A:B,2,FALSE),"")

How to create a count table of two variables in excel pivot

I am struggling with creating a count table of two variables at the same time. Ultimately, I would like to create a bar graph of the table.
Assuming I have two items for a sample of firms and I just want a summary table of the answer count.
Firm Item1 Item2
1 1 1
2 2 1
3 1 2
4 1 2
Based on this answer, I can easily create the summary table for Item 1 telling me that "1" appears three times for item 1 and two times in Item 2. But I cant easily create a Pivot table showing this jointly.
I'm not sure I understood correct, but is it COUNTIF() you need?
In D1 type:
=COUNTIF(B:B, "1")
that should give you result 3

EXCEL - Comparing Two Columns - Removing Repeats

If two households share, they create a tie and this tie has a kinship rank that does not change, no matter how often two households share with each other.
KINSHIP RANK EXAMPLE
As you can see, it doesn't matter in which "direction" the tie happened whether it was household 5 who shared to household 3 or vice versa, the kinship rank is still 1
HH1 HH2 RANK
5 3 1
3 5 1
Therefore, I do not need every tie that occurs between two households, but only the first instance that a tie occurred between the two households.
So here is a sample list of many households who shared with each other, sometimes sharing resources with themselves, sharing only once, or sharing multiple times with the same household.
TWO HOUSEHOLD WITH REPEATED TIES
COL.A COL.B
ROW HH1 HH2
1 1 1
2 1 2
3 1 3
4 2 1
5 2 4
6 3 1
7 3 2
8 3 4
9 4 2
This is what I need it to look like:
TWO HOUSEHOLDS WITHOUT REPEATED TIES
COL.A COL.B
ROW HH1 HH2
1 1 1
2 1 2
3 1 3
4 2 4
5 3 2
6 3 4
What I have done
I wrote a simple command for placing the HH1 and HH2 information into the same cell:
=A1&"|"&B1
In the case of the second row, this looks like 1|2 inside cell C2
HH1 and HH2 are combined in column C so how will I be able to compare all of the households in column C to each other? Perhaps a highlighting rule if a repeat happens? Or in another column list if it is a delete or a keep?
Thank you for your assistance everyone.
I suggest a simple COUNTIFS to do the job like this:
=(COUNTIFS(A$1:A1,B2,B$1:B1,A2)+COUNTIFS(A$1:A1,A2,B$1:B1,B2))>0
starting in C2 and then copy down. It will show TRUE for each row which is within the range above it and false if not. Ich checks for both x/y and y/x (the order doesn't matter)
Now simply filter col C to only show rows with TRUE in it. Then simply select and delete it.
This also works with non numerical values like names.
If you still have any questions, just ask ;)
You also can wrap it up to get more informations like this:
=IF((COUNTIFS(A$1:A1,B2,B$1:B1,A2)+COUNTIFS(A$1:A1,A2,B$1:B1,B2)),"",COUNTIFS(A:A,B2,B:B,A2)+COUNTIFS(A:A,A2,B:B,B2))
For C2 and copy down. C1 gets:
=COUNTIFS(A:A,B2,B:B,A2)+COUNTIFS(A:A,A2,B:B,B2)
This will show you only at the first occurrence how many times it is within the whole range.
All done by phone, may contain errors
Use =((A1*B1)/(A1+B1))*((A1*B1)+(A1+B1)) to create unique identifiers. Then use Remove Duplicates in the Data Tools Pane of the Data Tab to remove all rows containing duplicates. Or, alternatively, use something like =IF(IFNA(MATCH(A2,A$1:A1,0),TRUE())=TRUE,"First Share","") dragged and dropped from row 2 to identify First Shares.

PivotTable will not group ANYTHING

I have done some Googling and found other people had issues when their DATE fields were not true dates, had blank values, or where date values were not actual dates (e.g. 1/33/2015). However, none of these are true for my table.
I am also unable to group regular text fields into a new group like I used to be - I am working with ticket closures and want to Group "Cancelled" and "Completed" tickets into a Closed group and then all else into an Open Group.
I was able to do this on another Excel sheet a few weeks ago but now the option is completely grayed out.
Count of ETC Column Labels
Row Labels Closed-AS IS Complete New Pending Grand Total
John Doe 2 365 367
1/2/2015 2 2
1/5/2015 1 1
1/8/2015 1 1
1/15/2015 1 1
1/16/2015 1 1
1/20/2015 2 2
1/21/2015 2 2
1/22/2015 2 2
1/23/2015 1 1
1/26/2015 2 2
1/30/2015 1 1
2/2/2015 1 1
2/3/2015 2 2
2/4/2015 3 3
2/5/2015 1 1
2/6/2015 1 1
EDIT:
AHAH! Okay, so I've narrowed it down (still not resolved though). I am able to GROUP/UNGROUP utilizing an extrenal data source (in this case it's a .iqy file - or SharePoint List/Export). I am UNABLE to GROUP/UNGROUP when referencing a table defined on the actual workbook or on the Data Model.
This is not much of an answer but here's what I found.
PowerPivot, apparently, does NOT allow for GROUPING/UNGROUPING so if your data is added to PowerPivot's data model these options will be grayed out. Instead, you will have to "force" the data by creating new columns with whatever grouping logic you can build in DAX and then create a hierarchy out of them.

How to get the latest date with same ID in Excel

I want to Get the Record with the most recent date as same ID's have different dates. Need to pick the BOLD values. Below is the sample data, As original data consist of 10000 records.
ID Date
5 25/02/2014
5 7/02/2014
5 6/12/2013
5 25/11/2013
5 4/11/2013
3 5/05/2013
3 19/02/2013
3 12/11/2012
1 7/03/2013
2 24/09/2012
2 7/09/2012
4 6/12/2013
4 19/04/2013
4 31/03/2013
4 26/08/2012
What I would do is in column B use this formula and fill down
=LEFT(A1,1)
in column C
=DATEVALUE(MID(A1,2,99))
then filter column B to a specific value of interest and sort by column C to order these values by date.
Edit: Even easier do a two level sort by B then by C newest to oldest. The first B in the list is newest.
Do you need a programmatic / formula only solution or can you use a workflow? If a workflow will work, then how about this:
Construct a pivot table of your data
Make the Rows Labels the ID
Make the Values Max of Date
The resulting table is your answer.
Row Labels Max of Date
1 07/03/13
2 24/09/12
3 05/05/13
4 06/12/13
5 25/02/14

Resources