This question already has answers here:
RANDBETWEEN(1,11) but not 6?
(4 answers)
Closed 1 year ago.
Is there a way to use RANDBETWEEN for 2 ranges of numbers?
Perhaps something like:
=RANDBETWEEN(0,9 [and] 18,23)
This, way it can scan both ranges before spitting out a result.
=IF(RANDBETWEEN(0,15)<10,RANDBETWEEN(0,9),RANDBETWEEN(18,23))
The first randbetween gives you a random number for the total digits in each range. Burying it in and if function allows you to split the result on equal probability by setting the cut off at the first possible digit count in the next range. Once the range case has been decided, a randbetween of the appropriate range is performed.
Note this will only work for 2 ranges. If you have 3 or more ranges you would need to perform the first randbtween in its own cell, then in a second cell do the nested IF functions as required.
Your best option is probably the following:
=LET(Value,RANDBETWEEN(0,15),IF(Value<10,Value,Value+8))
I found something that worked for this:
=IF(RANDBETWEEN(1,2)=1,RANDBETWEEN(0,9),RANDBETWEEN(18,23))
Related
This question already has answers here:
How to use SUM function with (new) dynamic arrays in Excel
(4 answers)
Closed 1 year ago.
I have a 2D dynamic array of 0s and 1s (e.g. B1#). I want to calculate the number of 1s in each row. This can be done using SUM of each row or COUNTIFS on each row.
My goal is to have a single dynamic array formula which would sum/countifs each row and hence spill automatically according to the number of rows in the 2D dynamic array.
How do I do this?
What I tried:
I added a support column in A1# as Sequence(Rows(B1#))
I tried SUM(INDEX(B1#,A1#,0)) but obviously this doesn't work because SUM is bound to return a single value while I am expecting a spill of totals across ROWS(B1#)
I tried COUNTIFS(INDEX(B1#,A1#,0),1) but this also results in a single value that too #VALUE!
MMULT() with SEQUENCE() may work for you. Give a try on below formula.
=MMULT(B1:E14,SEQUENCE(COLUMNS(B1:E14),,,0))
This question already has answers here:
How can i count cells in excel? Need to count how many say win, and how many say loss [closed]
(2 answers)
Closed 5 years ago.
I am interested in Libre Office Calc, but it's perhaps similar or even identical as in Excel.
So, let's say I want to know how many cells in the column A have something in them.
How to count how many rows with some value are in the column A?
And I would like to display the result (number of cells/rows with somthing in them) in a B1 cell.
Any idea how to do it?
Try,
=countif(a:a, "something")
count is the way to go, theres a few versions, either
=countif(a:a,"value to count")
place what you want to count between "" unless its a number then dont use the ""
or
=counta(a:a)
will count anything with something in (includes text and numbers)
or
=count(a:a)
where only counts numbers
I am trying to write a function in Excel that says takes the average of a group of numbers if they are from AUM and have a certain name. I thought maybe I could do something like:
=AVERAGE(IF(('FY15'!$D$1:$D$652="AUM")*('FY15'!$B$1:$B$652=$A6),'FY15'!$W$1:$W$652))
But it does not return anything. I even tried to do it using SUM, how I have seen it, but still nothing. Any tips?
As Scott mentions in the comment to your question, this is probably easiest solved by using AVERAGEIF, or rather AVERAGEIFS since you have several criteria. I think the formula you'd want would be:
=AVERAGEIFS('FY15'!$W$1:$W$652,'FY15'!$D$1:$D$652,"AUM",'FY15'!$B$1:$B$652,$A6)
The first argument to the function is the range you want the average of.
Then the following argument is the first range which has a criteria
The third argument is the criteria you want to apply to the range specified in the second criteria.
Arguments 4 & 5 do the same as argument 2 & 3, but for a new criteria-range.
If you want even more criteria, add them in the same manner.
How can I do a simple summation of data that meets a certain condition? Say i have the data
1 2 3 4
5 6 -7 8
for finding the average I can just type in a cell =AVERAGE(A1:B4), but how can I find the average of only the positive numbers into a block of data?
I realize the IF statement would probably be used here, but how? Thanks for any help
You can use the AVERAGEIF function of Excel. The documentation is provided here. If your data was in cells A1:D2, the following function would only average the data that was above zero:
=AVERAGEIF(A1:D2,">0")
If you want to use multiple criteria, then you can use the AVERAGEIFS function, which is similar but allows multiple conditions. The documentation is provided here. The only catch is you have to define the range to average, which in your case could just be the same range. If your data was in cells A1:D2, the following function would only average the data that was both above zero and less than or equal to 6:
=AVERAGEIFS(A1:D2,A1:D2,">0","<=6")
Try: =AVERAGEIF(A1:B4;">0";A1:B4)
Works in excel 2013.
This question already has answers here:
Countif With Multiple OR Criteria
(4 answers)
Closed 8 years ago.
I have been googling this for a while and can´t seem to get it to work. I use Excel 2010 and want to count rows on a mix of AND and OR operators.
What I want to do is something like this
COUNTIFS($A:$A,"string1" , $B:$B,"string2" , $C:$C,{"stringA","stringB","stringC"})
This means mixing both AND and OR operator in the COUNTIFS function. Col A and col B must match the string criteria but col C must only match one of the values in the array given as criteria. Match on colA AND colB AND on one array value in col C.
A different approach would be to create one COUNTIFS function for each value in the array like
COUNTIFS($A:$A,"string1" , $B:$B,"string2" , $C:$C,"stringA") + COUNTIFS($A:$A,"string1" , $B:$B,"string2" , $C:$C,"stringB") + COUNTIFS($A:$A,"string1" , $B:$B,"string2" , $C:$C,"stringC")
This however is a lot of duplicate code and that bugs me! The logic solution would be to pass an array as criteria for column C. Also my array contains more then three values...
When I do this in Excel the formula is accepted and a few rows are counted but the results are way to low. It is not the result I´m expecting.
Any Excel-Pro out there that can tell me if this is possible? It would save me a lot of work!
Thanks!
you can use
=SUM(COUNTIFS($A:$A,"string1",$B:$B,"string2",$C:$C,{"stringA","stringB","stringC"}))
you can also use a similar array construction with sumproduct
=SUMPRODUCT(($A:$A="string1")*($B:$B="string2")*($C:$C={"stringA","stringB,"stringC"}))
Hmm, well, 'or' does make things longer. See a related question. I guess you could use =SUMPRODUCT() but still have it a bit long. Being an array function though, you'll have to use Ctrl + Shift + Enter.
=SUMPRODUCT(($A:$A="string1")+0,($B:$B="string2")+0,((($C:$C="stringA")+($C:$C="stringB")+($C:$C="stringC"))>0)+0)
Disclaimer: I haven't tested this yet.