Would like to retrieve data from range H, where any duration has negative number. Please bear in mind that I actually have over 10k rows and this is just an example.
try like this:
=FILTER(A:B; B:B<0)
You can try =QUERY(G5:H8,"SELECT A,B WHERE B < 0",1)
Related
I have an array of numbers and for every number I want to check if it's greater than a value in another cell and if it is greater I want to add the difference to the total sum.
I have succeeded to do this "manually" for an amount of cells but there must be a better way.
For simplicity I just compared the value to 10 but it will be another cell.
=sum(if(A1>=10,A1-10,0),if(A2>=10,A2-10,0),if(A3>=10,A3-10,0))
The formula abohe yields the expected result for A1:A3.
What unfortunately doesn't work is:
=SUM(if(A1:A3>=10,A1:A3-10,0))
At the end I changed my approach to arrive at the solution:
=SUMIF(A1:A3,">10") - COUNTIF(A1:A3,">10") * 10
So instead of summing the differences directly, we sum the appropriate values and then subtract the reference as often as we summed up.
Try with this:
=SUM(ARRAYFORMULA(IF(A:A="","",IF(A:A<=10,10-A:A,0))))
try:
=BYROW(A1:A20, LAMBDA(a, IF(a>=10, a-10, 0)))
or:
=SUMPRODUCT(BYROW(A1:A20, LAMBDA(a, IF(a>=10, a-10, 0))))
Sorry for maybe a lame posting, but I often encounter a need to return a pre-defined value x if cell exceeds y, but more efficient than below (due to often having long formulas)
Example below. I want cell to return 10 if
SUMIFS($AI$42:$AI$51;$AH$42:$AH$51;"<"&AH51)+1
is more than 10.
Is there a more efficient/elegant way than repeating this twice? i.e.
If((SUMIFS($AI$42:$AI$51;$AH$42:$AH$51;"<"&AH51)+1)>10;10;SUMIFS($AI$42:$AI$51;$AH$42:$AH$51;"<"&AH51)+1)
Thanks in advance!
Just put sumifs part into another cell, than use it in formula.
B1: =SUMIFS($AI$42:$AI$51;$AH$42:$AH$51;"<"&AH51)+1
RESULT: =If($B$1>10;10;$B$1)
If the result can't be higher than 10 then I'd go with MIN formula:
MIN(10, SUMIFS($AI$42:$AI$51;$AH$42:$AH$51;"<"&AH51)+1)
No extra cells, shorter and cleaner.
My current regex is : ^[0-9]{1,2}([,.][0-9]{1,2})?$ which allows for numeric values up to 99. I am not the greatest with regex and was wondering could someone help me to adjust this to include numbers in the hundreds, example, 100.
Edit: Its for money values.
For example I want to be able to withdraw money values, for example, 100:99, not 100:100.
It cannot be negative, and my program already prevents values less than 1 being entered.
Thanks
You can use this regex for 0..100 range (both inclusive):
^([0-9]{1,2}|100)$
OR for your example:
^([0-9]{1,2}|100)([,.][0-9]{1,2})?$
This should do: ^[0-9]{1,3}([,.][0-9]{1,3})?$
((^(100)([.][0]+)?$)|(^[0-9]{1,2}([.][0-9]+)?$))
This regular expression is for 0.0000.... to 100.000000....
Suppose I have the following vlookup command:
=VLOOKUP('Sheet1'!S2,'Sheet2'!$B$138:$C$145,2,FALSE)
When I drag the vlookup to the right I want it to update to
=VLOOKUP('Sheet1'!S2,'Sheet2'!$B$146:$C$153,2,FALSE)
In other words, I want the letters B and C fixed but the numbers to increment by 8. How would I do this?
It looks like your answer is always in column C and your lookup value in column A. If this is the case use INDEX MATCH
=INDEX ( C:C , MATCH ( 'Sheet1'!S2 , 'Sheet2'!$B:$C , 0 ))
I've made a few assumptions. Drop a pic of your tables and I can amend it if you can't work out which bits to change
That may be possible using some long if-then-else logic or macro but it seems an odd thing to do. The numbers represent rows so if you are incrementing them across columns I wonder whether you need to transpose your data and/or use HLOOKUP instead. There is probably a better way to achieve what you want but it is difficult to answer from the question as provided.
I am trying to work out how to do something using regular expressions.
Basically, I want to check if a number is equal to a base number (i.e. 2) to the power of n.
For example, I need something thats checks if number i == 2, 4, 8, 16 or 32 then do something.
Edit:
The problem lies where the number is actually coming from a varchar column in a legacy database. I could parse it out then do something like kobi reccommended but there is another problem where the number is in a delimited list i.e. (1,2,3,32). Therefore, I thought it would be easier to use regex as it would save a number of steps.
Thanks in advance.
In Python:
import re
a = str(bin(number))
if re.match(r"[^1]*1[^1]*$", a):
print "power of two"