Excel Data table - preserve manual entries in one column - sql

I have the following table layout in an Excel data table (fed by a SQL query):
Name, Birthday, Children, Check In
The first three columns come from a database query, the Check In column should be a column where I can manually enter an x for example.
Now, when I refresh the data table, the entries in the last column should stay in the right row. Currently, when I refresh the table the entries stay in the very same row they were entered in (e.g. if you enter an x into row 4, refresh and row 4 becomes row 5, the x stays in row 4).
Is there a way to avoid this?
Thanks in advance!

Hopefully you have some ID that uniquely identifies each item in each row (you could use the Name column if you don't have duplicate names). Keep a copy of your old data that you have marked the "Check In" box for. Then do a basic VLOOKUP to see whether that name has check in.

Related

How to identify a repeat column in postgreSQL, where the column has random input

I have two columns. ID, and Transcript. The numbers in the ID column are randomly generated. The Transcripts in Transcript are from an array that I cross-joined and unnested, which has generated several repeats of "ID" in Column 1 whenever there's multiple transcripts per ID.
I can't use the usual stack overflow "if" statements. The numbers in the ID column are randomly generated (and there's thousands of them), so I can't just write "if column ID is 'apple', then-."
I have to automatically identify when & where the column has a repeat, and then be able to take the second (and third, if there is one) rows, isolate the unique data in those rows, then append them onto the first row, in a new column. (I'm aware this would generate "null" data in other data rows' columns that don't have the new data. I presume I'd have to create new columns, pre-filled with '-' in them?)
I'm new to SQL, but does 'count' just tell the user the number of repeats for a particular input that the user specified?
Is there any way to write that number into a new column along a specific row (e.g., 'original instance of this ID') so that I can then issue a command based on that number? Otherwise, is it just telling the user how often something has repeated and isn't machine-readable to be used in additional steps?
Otherwise, can I number the duplicated IDs, then I can issue an order. 'if 1, insert into new column 1 row above if filled with '-. Else, insert transcript on the row above in new column 1 if column 1 has data '-'. Else if, put in column 2. etc.,'
I'm entirely lost as to how to even get it to recognise the duplication is occurring in a meaningful way, given the random nature of the ID system.

Table of data want to group, transpose matching values same line

I have a table of data in Excel. Column A contains Names, Column B contains their interest. Each interest has a separate row. I want to take the data from this table and have a single row with the name of the customer and a column for each of their interests. IE RAW Data:
I am looking to take the 4000 row table and grouping by the name. I am unsure how many times each name appears in the list (Once or Fifty times) but I want the interests placed on a single row with each interest in a separate column EG Desired Data:
I have tried the standard transpose....html table....and pivot tables but it will put the interests all in a row along the top regardless if the customer is interested or not and using a record count T/F that means the data sheet in harder to understand then if I leave it as one block and sort by name
Sure I am not alone with this but all searches for the past 2 hrs keep returning pivot/transpose or duplicate items. Any is appreciated
If you don't want to use VBA, you could first add a column, for instance in column C, with the title "InterestNum."
In C2, just put 1.
In C3, put =COUNTIF($A$2:$A2, $A3) + 1. This will find the number interest it is for the person.
Make a lookup column, for instance in column D. In D2, put =A2&C2
Then, make a list of all the people. I assume that you put this list starting in cell A2 of a new sheet. Then put headers starting in B1 so that B1 contains the title "1" and C1 contains the title "2" standing for the interest number and as many columns as you wish.
Then in Cell B2, put the formula =IF(ISNA(MATCH($A2&B$1,data!$D$2:$D$5,0)),"",INDEX(data!$B$2:$B$5,MATCH($A2&B$1,data!$D$2:$D$5,0)))
This assumes that your original data is in the data tab. I only tested with 4 rows, so you would need to change $D$2:$D$5 to have as many rows as you do. This works by looking up a combination of the name and interest number. It first checks to see if that combination exists in the data. If not, it leaves that interest blank. If so, it finds the actual interest by going to the same row of the lookup.
First remove duplicates using standard excel functionality to prevent having the same interest twice for a person.
Now, you could of course use VBA and perform exactly what you need.
However, I suggest that you use the pivot table.
If your data looks something like this...
... just use "Insert | Pivot table" and insert a pivot table to a new worksheet.
Then, configure the columns as follows:
Et voilĂ , there you have all your interests listed only once and if a person shares an interest, there is a "1".
If you would rather use VBA, just comment and I will edit my answer.

Data Validation between spreadsheets

I need to check whether a row from one table in one spreadsheet contains the same values for certain columns in another row in a table in a separate spreadsheet. This is going to be used for data validation.
For instance, I need to confirm that the item in row 2 of Table 1 has the same PO Number and Date of the item with the same Item Number (row 2) in Table 2.
I have included a link to an image containing the sample tables:
What is the best approach in tackling this problem? This is a simple representation because there are typically over 200 rows to be validated.

Return only changed columns between rows

I have a normal table structure. Like the one below
TableName_OID|GlobalKeyColumn(or foreign key)|Column2| ... |ColumnN|CreateBy|CreateDate|ModifyBy|ModifyDate|IsActive|IsUpdated|UpdateOfTableName_OID
I have written a before update trigger which will take the last row (with inserted.TableName_OID) and insert into the table with its [IsUpdated] = 1 and [UpdateOfTableName_OID] = TableName_OID (or I can insert a row that will only have changed columns' values but I dont know how).
For showing the whole history of table wrt a [GlobalKeyColumn] I have something in my mind. If I go with the first option (inserting a whole row), I will have to run a cursor on the resultset (for a certain GlobalKeyColumn) comparing each row with it's previous one and show only the changed columns.
What I need help with both the options is how to compare each column of a row to its previous one's. I mean, I can do it manually, but is there any generic thing in SQL Server that could compare all the columns in a row to it's previous one?

Add a specified # of record to MSAccess Table Automatically

Happy Holidays. I have two dependent tables, [orders] and [reviews], linked by a "one to many relationship". On the [Orders], the PK is [Order#], there is a column for [#_of_reviews_ordered]. On the [reviews] table (the PK is an auto number) the linked field is [order#] and the number of records (records on the table) should equal "[Orders].[#_of_reviews_ordered]".
Is there a simple way to accomplish this without having to do add the records to [reviews] manually?
The only way I can think to do this without VBA is fairly convoluted and would only work if your number of reviews orders fits within a finite (and reasonably small) range. For my explanation I will assume # of review will be between 0 and 3
You would need to create a table called, say, TemplateReviews. This would have at least one field called "KeyNumber", which should not actually be a key. You could also repeat as many fields as desired from Reviews, and use them to store default values for the rows to be inserted.
The important thing about TemplateReviews is that you must set it up in advance to have N rows with KeyNumber=N for each possible value of KeyNumber. For my example, we can have 0 to 3 # of reviews. So TemplateReviews will have:
0 rows with KeyNumber=0
1 row with KeyNumber=1
2 rows with KeyNumber=2
3 rows with KeyNumber=3
Once you have TemplateReviews set up, you need to create an Insert query based on it. The query will insert rows from TemplateReviews into Reviews. But you also have to filter KeyNumber to match the value on the currently selected Order, as in
=Forms!Orders![#_of_reviews]
You then need run Insert query to run using a macro triggered by a button (etc) on the Orders form. This only works the first time you click the button... but you can modify the criteria expression above to subtract the number of existing reviews, as in
=Forms!Orders![#_of_reviews] - DCount("*","Reviews","OrderId=" & Forms!Orders![order#])
Hope this helps. If you got this approach working, you could then replace the button with a single line of VBA code in the Order form AfterUpdate event to trigger the insert query.