I have a Google form accepting data from different users, which goes to a sheet and is used to SUM the values across columns at the end of the day. The problem is that users can re-submit forms to update the data totals if there is a change at the end of the day:
NAME K L M
ALF 4 0 1
BILL 1 0 0
SALLY 1 0 1
DENNIS 1 1 1
RICK 0 0 1
SALLY 2 1 1 <--- SALLY RESUBMITTED HER FORM AGAIN WITH UPDATED VALUES
In my current Query, I SUM() the columns after filtering by the date like this:
SELECT SUM(K), SUM(M), SUM(N) WHERE C = date '"&TEXT($B$1,"yyyy-mm-dd")&
$B$1 is a cell with a datepicker and col C is the user submitted form date. Col A has the unique form generated submission timestamps
As you can see, the SUM for each column will be off by the extra submission from Sally. I need to include only the most recent submissions from any of the users, and ignore any prior ones for this date. I'm not sure how to filter in this manner and sum just the most recent instance from each unique user.
** EDIT **
I should note the original form data is on another sheet and the cells are referenced via a query to this range. The form is also submitted daily, so the query must be able to specify the date in question for summation of entries.
Give a try on following formula-
=QUERY(INDEX(REDUCE({0,0,0,0},UNIQUE(J2:J7),LAMBDA(a,b,{a;SORTN(FILTER(J2:M7,J2:J7=b,C2:C7=date(2023,2,17)),1)})))," select sum(Col2), sum(Col3), sum(Col4)")
If you actually want most recent response to sum then use-
=QUERY(INDEX(REDUCE(SEQUENCE(1,COLUMNS(A2:M7),0,0),UNIQUE(J2:J7),LAMBDA(a,b,{a;QUERY(SORT(FILTER(A2:M7,J2:J7=b),1,0),"limit 1")}))),"select sum(Col11), sum(Col12), sum(Col13)")
Here you have another option, creating an auxiliary column that returns 1 if it corresponds to the date and is the last timestamp
=QUERY({K:M,
MAP(A:A,C:C,J:J,LAMBDA(ts,date,n,IF(date<>B1,0,IF(ts=MAX(FILTER(A:A,J:J=n,C:C=date)),1,0))))},
"SELECT SUM(Col1),SUM(Col2),SUM(Col3) where Col4=1")
In products table I have fields like
id product_name product_value quantity status
1 abc 10000 50 received
2 efg 5000 15 shipment
3 hij 850 100 received
4 klm 7000 20 shipment
5 nop 350 50 received
I can select multiple rows at a time. And here I selected id=2,4 and need to change the status='received'. How to do multiple update at single time in rails?
Try
Product.where(id: [2, 4]).update_all(status: 'received')
If you are looking for all products that have a status of 'shipment', you can use:
Product.where(status: 'shipment')
From here, you can set all to 'received', or iterate through them and select only the ones you want to make changes to.
I am using google sheets to do the following.
Sheet 1 : 1 column for each person who needs access to the file. Each column's cell has a dropdown menu so people can select what items they have.
Sheet 2 : A list of every item in column A, columns B through G are the names of the people.
What I am trying to do is to have on sheet 2, the words "YES" or "NO" appear under each person's name if they have selected the item whatever the order.
So if Person 1 picks in the dropdown of sheet 1 that they have Item 1, Item 3, Item 2 in this order, I want sheet 2 to show the "YES" or "NO" mention. I don't want the order of the items in the list to be an issue.
So far, I have tried these 2 methods :
=IF('Sheet1'!A2:A25=A2;"YES";"NO")
=IF(RegExMatch('Sheet1'!A2:A25;A2);"YES";"NO")
These do not work as the items must be selected in the same order as they appear in the second sheet. Is there another function that can validate a list in any order and apply the appropriate value?
Thanks ahead!
Jason
Edit : https://docs.google.com/spreadsheets/d/1cNn7G9x9o56d_9qM18s3AULkhpfOV5Y-b55vycCUyLY/edit?usp=sharing
Sheet2!B2:
=ARRAYFORMULA(IF(ISERROR(MATCH($A$2:$A$100;Sheet1!A2:A25;0));false;true))
MATCH Sheet1A column against Sheet2A column
IF MATCH returns error, FALSE, else TRUE.
I have the following records in my data base
fields: brand |model |attributes
----------------------------
record 1) apple |iPhone|6s space grey sprint
record 2) audi | a6 |quattro coupe
How can I store the attributes into different column names, with version/color/carrier columns for the first record and engine/type as the different columns for second record. The table should have 5 total columns for 1st record and 4 columns for the second record.
How do I achieve this? Should I split the table? If there are million products and each have varied length attributes then the number of columns in the table will be long. Whats the efficient way of doing this?
You can store the related attributes in a second table.
record|attribute|value
------+---------+-----
1 |version |6s
1 |color |space grey
1 |carrier |sprint
2 |engine |quattro
2 |type |coupe
This would allow for an item to have any number of (optional) attributes.
I want to obtain reccomendations on the most purchased item for an order with a specific item so for example if I have such table
user order items purchased
1 1 1,3
1 2 2,3
2 1 3
3 1 2,4
3 2 1,2,4
if I visit the page of item 2 I want item 4 as suggested product because it is present on the rows 2,4 and 5 while the item 3 is present only on row 2 (I am considering just orders with the item 2 in it) (note that the item 3 is the most purchased but I don't want it as suggested since I am looking at item 2). What kind of problem is this? Is it an item reccomender? Is it doable in Mahout or should I implement it by hand? Since it is not possible to model multiple preferences per same user and item, I have thought to convert the string user_order to userId.
Thanks very much
Yes this is a very simple recommender problem. I think you want to ignore 'order'. So your data is more like:
1,1
1,3
1,2
2,3
3,2
3,4
3,1