I have data in google sheet and I want to get this
I have numbers value in B Column and want to multiply based on condition, Like if numbers above 650 in column B then formula insert value in Column C 125 if value bellow 650 in column B then formula multiply value with 0.16 like 648*0.16 and want final result in column C. If value above 850 in Column B then also formula multiply value with 0.16 like 855*0.16 and final result in Column C .
Here is ex:
Sorry for the bad English.
I tried this
=B2 * IF(B2 > 650,(0+125), IF(B2 < 649,0.16, IF(B2 < 850, 0.16, 0)))
but it does not insert 125 value as its X with 125 I don't want to multiply if value above 650 and bellow 850. so please help me with this.
you can use arrayformula:
=ARRAYFORMULA(IF(B2:B<>"", IF((B2:B > 649)*(B2:B < 850), 125, B2:B* 0.16), ))
See if this works
=IF( AND (B2 > 649, B2 < 850), 125, B2* 0.16)
Related
I have a dataframe with 3,000,000 IDs. Each ID has the month range from 2015-01-01
t0 2018-12-01. Each ID has column "A" and "B" with numeric values. I need to create a new column "C:.
For each ID, when Date == '2015-01-01' which is the first month for that ID, column C value equal to exp(column_A value).
For the next month (Date == '2015-02-01'), column C value equal to exp(log(column_C_value in previous month) + column_B_value at this month), so here is exp(log(column C # 2015-01-01) + column_B # 2015-02-01). Each of the following months has the same pattern until it reaches 2018-12-01.
In Python, I can setup the loop for each ID and for each row/month, such as:
for ID in range(xxx):
for month in range(xxxx):
However, such calculation takes long time. Can anyone tell me a faster way to do this calculation? Very appreciated for your help!
Consider that
(1) exp(x+y) == exp(x)*exp(y).
And
(2) exp(log(x)) == x.
So exp(log(c1) + b2) == c1 * exp(b2).
The next value simplifies to c1 * exp(b2) * exp(b3), and so on.
That means, you have to multiply all exp(b) values, which can be turned
into adding all(b)-s and then applying exp() to the result.
And don't forget to multiply it with a1, the initial value.
a1 * exp(b2 * b3 * ...)
I am trying to build a spreadsheet that keeps track of my inventory. I want to use the First In First Out approach and need the formula to solve the following problem. I want to subtract the value 16 from the list of stocks over multiple rows.
Value= 16
Column A --> Column B
10 0
5 0
2 1
3 3
12 12
delete everything in B column and use this ArrayFormula like:
=ARRAYFORMULA(
IF(IF(A4:A="", ,{B1; (SUMIF(ROW(A4:A), "<="&ROW(A4:A), A4:A)-B1)*-1})>A4:A, 0,
IF(IF(A4:A="", ,{B1; (SUMIF(ROW(A4:A), "<="&ROW(A4:A), A4:A)-B1)*-1})>0, A4:A-
IF(A4:A="", ,{B1; (SUMIF(ROW(A4:A), "<="&ROW(A4:A), A4:A)-B1)*-1}), A4:A)))
Sample below:
Subtract: B2 = number [16]
Subtract: B3 = formula =B2-A2. Copy down.
Out: C2 = formula =IF(B2>A2,0,IF(B2>0,A2-B2,A2)). Copy down.
Is it possible to have a range of values in a cell so that Sheets understands it when calculating something?
Here's an example of the desired output:
A B C
1 Value Share Total sum
2 100.00 90-110% 90-110
Here, Total sum (C2) = A2 * B2 (so 100 * 90-110%), giving a range of 90-110.
However, I don't know how to insert this range of values into a cell without Sheets saying #VALUE!.
you will need to do it like this:
=REGEXREPLACE((A2*REGEXEXTRACT(B2, "\d+")%)&"-"&
A2*REGEXEXTRACT(B2, "-(\d+%)"), "\.$", )
for decimals:
=REGEXREPLACE((A40*REGEXEXTRACT(B40, "\d+.\d+|\d+")%)&"-"&
A40*REGEXEXTRACT(B40, "-(\d+.\d+%)|-(\d+%)"), "\.$", )
AL-CHE-P1-1518 --- 270
AL-CHE-P2-1318 --- 280
AL-MAT-P1-1218 --- 280
AL-MAT-P4-0918 --- 40
all these data are inside same cell C2, my aim is to derive a formula to sum
270+280+280+40
in cell D2
tried regextract(c2,"\d(.*)\n") but only the first "270" is extracted, I need help, searched through all forums, couldn't get exact match, it will save me huge time if anyone could give me some hint on how to derive the sum inside same cell string
As far as I know, you can only accomplish this via a UDF:
Function ReturnSum(rng As Range) As Long
Dim arr As Variant
arr = Split(rng.Value, Chr(10) & Chr(10))
For i = 0 To UBound(arr)
ReturnSum = ReturnSum + Trim(Split(arr(i), " --- ")(1))
Next i
End Function
=SUMPRODUCT(ARRAYFORMULA(REGEXEXTRACT(SPLIT(C2,CHAR(10))," \d+")))
In Excel the formula is a bit more complicated and an array formula:
=SUM(IFERROR(--MID(TRIM(MID(SUBSTITUTE(A1,CHAR(10),REPT(" ",99)),(ROW($XFD$1:INDEX(XFD:XFD,LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(10),""))+1))-1)*99+1,99)),FIND("---",TRIM(MID(SUBSTITUTE(A1,CHAR(10),REPT(" ",99)),(ROW($XFD$1:INDEX(XFD:XFD,LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(10),""))+1))-1)*99+1,99)))+3,99),0))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when Exiting Edit mode.
Can someone pl tell me what is rolling sum and how to implement it in Informatica?
My requirement is as below:(Given by client)
ETI_DUR :
SUM(CASE WHEN AGENT_EXPNCD_DIM.EXCEPTION_CD='SYS/BLDG ISSUES ETI' THEN IEX_AGENT_DEXPN.SCD_DURATION ELSE 0 END)
ETI_30_DAY :
ROLLING SUM(CASE WHEN (SYSDATE-IEX_AGENT_DEXPN.ROW_DT)<=30 AND AGENT_EXPNCD_DIM.EXCEPTION_CD = 'SYS/BLDG ISSUES ETI'
THEN IEX_AGENT_DEXPN.SCD_DURATION ELSE 0 END)
ETI_30_DAY_OVRG :
CASE WHEN ETI_DUR > 0 THEN
CASe
WHEN ROLLINGSUM(ETI_DUR_30_DAY FOR LAST 29 DAYS) BETWEEN 0 AND 600 AND ROLLINGSUM(ETI_DUR_30_DAY FOR LAST 29 DAYS) + ETI_DUR > 600 THEN ROLLINGSUM(ETI_DUR_30_DAY FOR LAST 30 DAYS) - 600
WHEN ROLLINGSUM(ETI_DUR_30_DAY FOR LAST 29 DAYS) > 600 THEN ETI_DUR
ELSE 0 END
ELSE 0 END
And i have implemented as below in Informatica.
Expression Transformation:
o_ETI_DUR-- IIF(UPPER(EXCEPTION_CD_AGENT_EXPNDIM)='SYS/BLDG ISSUES ETI',SCD_DURATION,0)
o_ETI_29_DAY-- IIF(DATE_DIFF(TRUNC(SYSDATE),trunc(SCHD_DATE),'DD') <=29 AND UPPER(EXCEPTION_CD_AGENT_EXPNDIM) = 'SYS/BLDG ISSUES ETI' ,SCD_DURATION,0)
o_ETI_30_DAY -- IIF(DATE_DIFF(TRUNC(SYSDATE),trunc(SCHD_DATE),'DD') <=30 AND UPPER(EXCEPTION_CD_AGENT_EXPNDIM) = 'SYS/BLDG ISSUES ETI' ,SCD_DURATION,0)
Aggregator transformation:
o_ETI_30_DAY_OVRG:
IIF(sum(i_ETI_DUR) > 0,
IIF((sum(i_ETI_29_DAY)>=0 and sum(i_ETI_29_DAY)<=600) and (sum(i_ETI_29_DAY)+sum(i_ETI_DUR)) > 600,
sum(i_ETI_30_DAY) - 600,
IIF(sum(i_ETI_29_DAY)>600,sum(i_ETI_DUR),0)),0)
But is not working. Pl help ASAP.
Thanks a lot....!
Rolling sum is just the sum of some amount over a fixed duration of time. For example, everyday you can calculate the sum of expense for last 30 days.
I guess you can use an aggregator to calculate ETI_DUR, ETI_30_DAY and ETI_29_DAY. After that, in an expression you can implement the logic for ETI_30_DAY_OVRG. Note that you cannot write an IIF expression like that in an aggregator. Output ports must use an aggregate function.
Here is a rolling sum example:
count, rolling_sum
1,1
2,3
5,8
1,9
1,10
Basically it is the sum of the values listed previously. To implement it in Informatica use 'local variables' (variable port in expression transformation) as follows:
input port: count
variable port: v_sum_count = v_sum_count + count
output port: rolling_sum = v_sum_count
we have a moving sum function defined in Numerical functions in Expression transformation:
MOVINGSUM(n as numeric, i as integer, [where as expression]).
Please check if it helps.