Is it possible to give a cell a different value than it displays? - google-sheets

What I mean by this is maybe explained easiest with an example:
I habe a list of items and every item has a name and an ID.
I want to sort that list by ID, with the exception to have item "XYZ" with ID 24 alwas on first place. So I would like to give it's ID-cell the value 0 (for sorting) but it should still show the value 24.
Sounds weird and is probably not possible?
Edit: I want it to look like this:
If the user is sorting (using the filter drop down menu) by ID column, it should be sorted as it's in this picture.
I found a solution for the first ID (Hans): Custom number format for that cell:"0;0;"24". It will show the value 0 as '24'. That doesn't help for Franz tho. Here I want a value between 5 and 7 showed as '??'.

A possible solution would be creating a second ID and sorting the values based on this new ID. Something like this:

If you are sorting through formula in other columns you can use:
=SORT(A2:B,MAP(B2:B,LAMBDA(id,IF(id=24,0,id))),1)

Exclude that first item from sorting then merge again. Try the following formula.
={A1:B2;SORT(A3:B,2,1)}

Built an array youself for sorting with IF(A1:A7=24,0,A1:A7), so that XYZ will have its weight as 0,
place it next to your data as the 3rd column with {},
use QUERY() to sort the data and get rid of the 3rd column.
Formula:
=ArrayFormula(
QUERY({A1:B7,IF(A1:A7=24,0,A1:A7)},
"Select Col1,Col2 Order By Col3 ASC",
1)
)

I found the solution (with a little help):
For only the cells you want to show "Something else" but be handled as the values, edit the Custom number format to:
By this, it will always show what you put in there, no matter what value the cell has.

Related

Adding values based on other values but SUMIF is quite right

Here is a link to my spreadsheet. Essentially what I am looking for is if the task matches then I want to also be able to give a Tech level then from there add up the values. I put a note in the sheet but basically if I give a task value and a tech level I want the corresponding value but whenever I try to do multicolumn adding in my sumif it just gives me the value from the first column.
An example of the formula I want is something like =SUMIF(Name, Name2 and Rank, Add Values).
try:
=INDEX(IFNA(VLOOKUP(K3:K&"♥"&L3:L, SPLIT(FLATTEN(
IF(B2:D="",,A2:A&"♥"&B1:D1&"×"&B2:D)), "×"), 2, 0)))
I think what you are looking for can be done by using a Index-Match function.
e.g. If you paste the following formula in an empty cell somewhere in the sheet,
=INDEX($A$1:$D$8, MATCH("Task 1",$A$1:$A$8,0),MATCH("Tech 2",$A$1:$D$1,0))
it gives you 20 corresponding to Task 1 and Tech 2.
If you paste the following in an empty cell somewhere in sheet,
=INDEX($A$1:$D$8, MATCH("Task 7",$A$1:$A$8,0),MATCH("Tech 3",$A$1:$D$1,0))
it gives you 36 corresponding to Task 7 and Tech 3.

google sheets (h)lookup last non-null value in specific column

I'm trying to populate a column with the last known price at the end of a batch of orders.
Please see an example attached.
I need the last price known from columns "price". Please note that there is not always value.
I tried something like this : =LOOKUP(B2:H2,"price",B3:H3<>"")
But it didn't really work.
(the nos 18 and 3 in column "I" are just examples. I need the green 3 results),thx.
Maybe try:
=INDEX(FILTER(B3:H3,B$2:H$2="price"),COUNTIFS(B$2:H$2,"price",B3:H3,"<>"))
If there could be empty gaps in your data, try this alternative:
=INDEX(A3:H3,MAX(COLUMN(A3:H3)*(A$2:H$2="price")*(A3:H3<>"")))

How to seach column for all text matches in column A and sum all of the corrosponding values in column B Excel

I'm sure this is possible, but I've been trying various ways for the past 2 hours and can't find the solution.
I need to find all the instances of a text name in column A, lookup all the numerical results in column B and sum them together.
I thought =ArrayFormula(sum(lookup(F2,$A$2:$B$1000))) would do the trick, but it's only picking up the last value on the last mention and not all the values of all the mentions.
I've attached a spreadsheet to show the data I'm looking at.
Thanks to the reference from BigBen to check out Sumifs. Using this command, the following works a treat:
=SUMIFS(B2:B3115,A2:A3115,F2)
try:
=QUERY(A2:B; "select A,sum(B) where A is not null group by A label sum(B)''")

Filter unique values based on secondary attribute

I've filtered unique values (discarding blanks) from one sheet to another. I'd now like to add the equivalent of an 'if' to display unique values that also have a value attached to it.
To illustrate my point I've highlighted the values (green) of the values I'd like to carry through.
My current formula:
=UNIQUE(FILTER('Sheet2'!A1:A33,'Sheet2'!A1:A33<>""))
The working sheet(s) can be found here. I figured it's be easier than describing it in text.
https://docs.google.com/spreadsheets/d/1svoiYRZA0VP76HEjWYmJWd_j57Qf5HOHXNDlnpjfkqM/edit?usp=sharing
The formula in question is in cell A1 on Sheet1.
Thanks in advance.
You can add that condition in your filter function.
=UNIQUE(FILTER(Sheet2!A1:A33,Sheet2!A1:A33<>"", Sheet2!B1:B33>0))
If you want to return name AND value, try
=UNIQUE(FILTER(Sheet2!A1:B33,Sheet2!A1:A33<>"", Sheet2!B1:B33>0))
=FILTER(Sheet2!A:G,Sheet2!A:A=UNIQUE(Sheet2!A:A))
for my case,
unique column A,
bring along value B to G.

How can I filter my search in a column on google sheet which collects data from a form?

I would like to perform a multi criteria search of data in a column- contains data of check boxes(more than one option chosen).
For a clearer picture of what I am trying to do, screenshot below is a question in a form
Data from the form are saved in sheets like below,
So my concern here is if I would like to search/filter for the rows that contain "Commercial", the rows with Commercial,Engineering doesn't show up. That's definitely not an effective search.
Any advise on how can I go about this issue is kindly appreciated. If
Let's say you have your form in the response sheet in columns A to P, with the multiple choice in col D. If you want to filter your data on the word 'Commercial' you can either do:
=filter(A2:P, regexmatch(A2:P, "Commercial"))
or use query():
=query(A2:P, "select * where B contains 'Commercial' ")
Note: depending on your locale you may have to change the commas to semi-colons in order for the formulas to work.
I hope that helps ?
Following JPV's answer, I developed a line to make the query useful if you want to cross two categories. Let's suppose that someone in your checkbox example had picked all the options (IT, HR, Commercial, Engineering); and that you have created the cell with the dropdown option box in cell B1 with all your options, as JPV said.
Then, you want to filter and see all the people who had chosen IT and Commercial. You would, for that, create a second cell with the dropdown option box in, lets say C1; and then your query would be:
=query(A2:P, "select * where B contains '"&B1&"' and B contains '"&C1&"' ")
=FILTER(MOBILE!A2:E2000, ISNUMBER(SEARCH(A1,MOBILE!A2:A2000)))
SEARCH function will return a number of the position of the searched word (A1) in the searched strings in range (MOBILE!A2:A2000).
If the result of search is a number (ISNUMBER), then filter will return the TRUE rows result from the range MOBILE!A2:E2000.

Resources