How does one use a string value as a random value, I have 3 values namely SMS, Datasynergy and Other, i want to simulate live data by using the random function to assign one of the aforementioned value to my field at random?
The way i thought of it is to make a random value between 1-3 and and then go on to say if 1 = SMS else if 2 = Datasynergy else Other
But im pretty sure there must be other ways of doing this?
Thanks in advance.
try this
=CHOOSE(RANDBETWEEN(1,3),"SMS","Datasynergy","Other")
Another way is to use INDEX, e.g.
=INDEX({"SMS","Datasynergy","Other"},RANDBETWEEN(1,3))
which you can easily adapt for a longer list like this
=INDEX(List,RANDBETWEEN(1,COUNTA(List)))
Related
I don't know if you consider that excel is a valid programming language to ask in there, but I need this for a project.
In the switch() function, I said to compare the max value of those cells to return the one that coincides, but when two values are the same, it returns the one who is first.
=SWITCH(MAX(J3:J7);J3;"Jugador 1";J4;"Jugador 2";J5;"Jugador 3";J6;"Jugador 4";J7;"Jugador 5")
How could I make it to return "Jugador 2, Jugador 3" instead of just one of them?
I don't figure what function can do something like that. I thought of making something like to functions in one but don't know.
Welcome!
There are several different techniques to accomplish this task. One of them is using a combination of TEXTJOIN() and IF() functions in array formula:
{=TEXTJOIN(",";1;IF(J3:J7=MAX(J3:J7);A3:A7;""))}
what is the easiest way with an Excel formula to extract certain details from a cell? So for example, if this is in cell A1 column=""HMI_LOCATE"" px=""CLASS"" position=""99"" validation=""ROOM"" then I'm trying to extract just the data the falls in between the double "" after the px= so in this example, I need to extract just the letters CLASS and nothing else, what is the easiest way to extract that data, the part I'm trying to extract won't always be 5 characters long it could be much longer or shorter.
Do you want to achieve this?
With o365 you can use this formula
=FILTERXML("<t><s>"&SUBSTITUTE(A1,CHAR(34)&CHAR(34),"</s><s>")&"</s></t>","//s[position() mod 2 = 0]")
or for older EXCEL-versions
=IFERROR(INDEX(FILTERXML("<t><s>"&SUBSTITUTE($A$1,CHAR(34)&CHAR(34),"</s><s>")&"</s></t>","//s"),ROW(A1)*2),"-")
This splits the string at the quotation marks (CHAR(34)) and builds an array of elements. Then every second element is put out.
For tons of other possibilities have a look at this awesome guide by JvdV.
EDIT:
To get the element after px= no matter where it is, you can use
=LET(list,
FILTERXML("<t><s>"&SUBSTITUTE($A$1,CHAR(34)&CHAR(34),"</s><s>")&"</s></t>","//s"),
INDEX(list,MATCH("px=",list,0)+1)
)
The LET-function lets you assign functions to variables which then can be used for further calculations.
The idea is that:
I separate full names into 2 other columns like fname + lname.
Then, I concatenate fname.lname to create a username.
So, we have got:
fname.lname#server.com
However, sometimes we find out there are few equal usernames and we need to handle it to become different from each other.
Then, we wanted to make an incrementation every username repeatition:
fname.lname1#server.com
fname.lname2#server.com
fname.lname3#server.com
How to meet this condition when working with EXCEL?
I'm really beging your help guys!
How to AUTO make SequecialUserName happens in Excel
Use COUNTIFS:
=A2&"."&B2&IF(COUNTIFS(A:A,A2,B:B,B2)>1,COUNTIFS(A$2:A2,A2,B$2:B2,B2),"")&"#server.com"
Say I have multiple tasks: quoting, binding, rating that have same response time of 3 hours... I was wondering if there was a way to make an IF statement such that I could just say for example:
=IF(B2="*Quoting,Binding,Rating", C2+3, NA)
I haven't been able to get it to work, and I'm trying to avoid using an OR statement with the IF statement to get the values, but is it possible to do it this way? It sounds simple, "If it's task x,y,z then add 3 hours to the start time column (C2)". Any advice guys? Thanks!
This may achieve what you're after
=IF(NOT(ISERROR(SEARCH(B2,"Quoting,Binding,Rating"))), C2+3, "NA")
Hope that helps
Use the OR statement: =(IF(OR(B2="Quoting",B2="Binding",B2="Rating"),C3+3,NA()))
If you're looking to shorten the formula, you can put the values you want to check into a named range (I used "List" to reference "I:I" but you could put the list on another sheet) and use SUMPRODUCT.
=IF(SUMPRODUCT(--(B2=List))>0,C3+3,NA())
Let's say i have a list of the alphabet
myList=["a","b","c"..."z"]
Now lets say we have a variable within a loop that takes out a random letter from the list. Obviously random is imported.
while True:
ans=myList[random.randint(1,26)]
I want the user to be asked to take a guess at a letter so within the loop i add
guess=input('Take a guess at a letter from the alphabet')
The user will receive a clue on the whereabouts of the answer
print('The letter locates between x and x.')
Question. How can i determine the position of ans in myList so i can give two random values and perhaps assign them to variables, one below ans and one value over ans.
The range would always be random between these two values so ans is not always the median of the two values.
p.s. I would put the script together to give a better view of what it looks like, but unfortunately i find the formatting help very confusing, and highlighting pieces of code and pressing Ctrl+K does not work as simply as i expected.
The position is the output of the random call, right?
You can save that to a variable before calling the myList[]
index = random.randint(1,26)
ans = myList[index]
use
myList.index(ans)
for above code to work you need to have ans in myList or else it will throw an exception.
BTW this question is similar to Finding the index of an item given a list containing it in Python