input value in one column if values in another are the first instance above a new floor.math integer - excel

I have two columns in Excel. I would like to populate col1 with number 25 if in col2 it is greater than 80000. But, I only want the number 25 to appear the first time the value in col2 is g>= than a multiple 80000. Lastly, the number 25 should appear again the first time a value in col2 is >=160000...and so on.
VALUE expected output
1,631
39,716
85,022 25
123,192
151,744
173,125 25
190,520
205,108
217,553
228,323
237,753
254,024 25
299,957
331,953 25
354,286
333,296
297,460

In B2:
=IF(INT(A2/80000)>0,IF(INT(A2/80000)<>INT(A1/80000),25,""),"")
and copy down

Related

subtracting values between columns both ways

I need to find those values that are in column 1 and not in column 2 and vica versa. It can look like this: take fist row in the first column and look if there is same number in the second column if so then on the third column write 0 (substraction) and if there won't be the same number then write searched number or error, doesn't matter. This should work both ways (some numbers can be in col2 but not in col1, those i need to find aswell). So probably there would be 2 formulas in 2 columns. one searching from col1 to col2, and same for col2 to col1. And if there for example in col1 would be twice some value and in col2 just once, than it should show for the first number 0 and for second number error or searched number.
Dataset looks like this:
Col1
Col2.
42646
55
42646
77
33
25
77
Col3
Col4
0
55
0
0
33(or error,NA etc)
25
0
I have tried vlook up, but wasn't sucesfull.
I guess this is what you are looking for. You can use for Col3:
=IF(A2:A6="", "",IF(ISNA(XMATCH(A2:A6,B2:B6)),A2:A6,0))
and for Col4:
=IF(B2:B6="", "", IF(ISNA(XMATCH(B2:B6,A2:A6)),B2:B6,0))
Both formulas returns 0 if the value was found (including blanks), otherwise the missing value.
You can put all together using HSTACK:
= HSTACK(IF(A2:A6="", "",IF(ISNA(XMATCH(A2:A6,B2:B6)),A2:A6,0)),
IF(B2:B6="", "", IF(ISNA(XMATCH(B2:B6,A2:A6)),B2:B6,0)))
Or using LET to avoid repetitions.
= LET(A, A2:A6, B, B2:B6, HSTACK(IF(A="","",IF(ISNA(XMATCH(A,B)),A,0)),
IF(B="", "", IF(ISNA(XMATCH(B,A)),B,0))))
Here is the output:
You can use XLOOKUP too, but the formula is longer, because the first three input arguments are required:
=IF(ISNA(XLOOKUP(A2:A6,B2:B6, A2:A6)),A2:A6,0)
A shame you haven't added a sample in your data that would show what you meant with:
"And if there for example in col1 would be twice some value and in col2 just once, than it should show for the first number 0 and for second number error or searched number."
Your requirements make this a little tricky, but try:
Formula in C1:
=IF(A1="","",IF(COUNTIF(B:B,A1)-COUNTIF(A$1:A1,A1)<0,A1,0))
Formula in D1:
=IF(B1="","",IF(COUNTIF(A:A,B1)-COUNTIF(B$1:B1,B1)<0,B1,0))

MS excel calculate sum by conditions

I have a table:
col1
col2
134
1
432
2
222
3
21
4
982
5
1352
8
111
9
I need to find all possible sum combinations of col1 values IF col2 sum is 10. (5+4+1, 2+3+5, etc.) & number of terms is 3
Please advice how to solve this task?
To get all unique possible sums based on a give count of items in col2 and sum of col2 is a specific amount, with ms365, try:
Formula in D1:
=LET(inp,B1:B7,cnt,3,sm,10,B,COUNTA(inp),A,MAKEARRAY(B,cnt,LAMBDA(r,c,INDEX(inp,r,1))),D,B^cnt,E,UNIQUE(MAKEARRAY(D,cnt,LAMBDA(rw,cl,INDEX(IF(A="","",A),MOD(CEILING(rw/(D/(B^cl)),1)-1,B)+1,cl)))),F,FILTER(E,MMULT(--(E<>""),SEQUENCE(cnt,,,0))=cnt),G,FILTER(F,BYROW(F,LAMBDA(a,(SUM(a)=sm)*(COUNT(UNIQUE(a,1))=cnt)))),UNIQUE(BYROW(G,LAMBDA(a,SUM(XLOOKUP(a,inp7,A1:A7))))))
You can now change parameters cnt and sm to whichever amount you like.
The trick is borrowed from my answer here to calculate all permutations first. Instead of a range, the single column input is extended using MAKEARRAY().
A short visual representation of what is happening:
Expand the given array based on cnt;
Create a complete list of all possible permutations;
Filter step 2 based on a sum per row and unique numbers (don't use values from col2 more than once);
Lookup each value per row to create a total sum per row;
Return only the unique summations as per screenshot at the top.

How to snip part of a rows' data and only leave the first 3 digits in Python

0 546/001441
1 540/001495
2 544/000796
3 544/000797
4 544/000798
I have a column in my dataframe that I've provided above. It can have any number of rows depending on the data being crunched. It is one of many columns but the first three numbers match another columns data. I need to cut off everything after the first 3 numbers in order to append it to another dataframe based off of the similar values. Any ideas as to how to get only the first 3 numbers and cut off the remaining 8 values?
So far I've got the whole column singled out as a Series and also as a numpy.array in order to try to convert it to a str instead of an object.
I know this is getting me closer to an answer but i can't seem to figure out how to cut out the unnecessary values
testcut=dfwhynot[0][:3]
this cuts the string where i need it, but how do i do this for the whole column is what i can't figure out.
Assuming the name of your column is col, you can
# Split the column into two
df['col'] = df['col'].apply(lambda row: row.split('/'))
df[['col1', 'col2']] = pd.DataFrame(df_out.values.tolist())
col1 col2
0 546 001441
1 540 001495
2 544 000796
3 544 000797
4 544 000798
then get the minimal element of each col1 group
df.groupby('col1').min().reset_index()
resulting in
col1 col2
0 540 001495
1 544 000796
2 546 001441

Compare cell in excel

i have some data like below in one column.
Value
-----
A#show
20
20
B#show
20
25
30
C#show
10
10
10
10
D#show
10
E#show
10
20
I want to compare the values between the cell where the last string is "show" and if there is only one then no comparison.
Value Comparison
----------------------
A#show Same
20
20
B#show different
20
25
30
C#show same
10
10
10
10
D#show only one
10
E#show different
10
20
I think it's can be possible using a VBA script
It's a bit unclear what you're trying to compare between values. However, there is a way to do this without VBA.
1) In the Second Column, create a "Header" column which names which header each value belongs to. The first entry would just be A#show, but then the following would be:
=IFERROR(IF(A2*1>0,B1),B2)
2) In the third column, you can utilize countif to see if the header has more than 2 entries (indicating it has a comparison). Here is where you can apply whatever comparative metric you'd like. If it's something unformulaic, just use a pivot table with the 3 columns.

Is there any range or between kind of function in Excel?

I have a table with three columns in Excel, a,b and c.
One cell has a numeric value X [say 25], I need to get the value in the c column such that X should be in between min and max column. For X=25 the value in c is "20" since X is between the min and max values for the 5th table row.
I'm looking for a range or between kind of function, but couldn't find a function with either name.
a b c
-----------------------------
min max improvements
0 1 70
2 5 60
6 10 50
11 20 30
21 30 20
31 40 10
41 80 5
You want to look up in that table of yours which improvement value is correct if some value is "25"; in this case that would mean to match line 5 of your table and return the value 20.
You are looking for VLOOKUP, e.g.
=VLOOKUP(B12;A2:C8;2)
giving
(edit: fixed stupid typo in formula and image, now giving correct result)

Resources