Can I make the values of an IF function into equations? - if-statement

I'm working on a simple budget sheet in Google Sheets, and want to know if I can make the values of an IF function into an equation.
Column A describes the activity (as in, purchased DVD, received paycheck, etc).
Column B lists the amount of the activity if it was income; otherwise, it remains blank.
Column C lists the amount if the activity was an expense; otherwise, it remains blank.
Column D is my total amount, which takes the total amount in the cell directly above it and either adds to that value with the value in column B, or subtracts from that value with the value in column C. I have to personally input that equation, which is pretty time-consuming.
I was hoping to use column E to be a row that I mark as "Y" if that row was income. Otherwise, I would leave it blank.
Then I wanted to replace the equation in column D with an IF statement that checks if column E has a "Y" in it. If it does, then it performs the addition equation using columns D and B. (And if E is blank, then the equation simply has column C subtracted from column D.)
Say I have the following table:
1. Col. A || Col. B || Col. C || Col D.
1. Event || Income || Expense || Total
1. START VAL.||--------||---------|| $100.00 ||
2. Hamburger ||--------|| $10 || =D3-C4 ||
3. Paycheck || $20 ||---------|| =D4+B5 ||
Instead, I'm hoping to add column E so the table looks like this:
1. --Col. A---||-Col. B-||--Col. C-||----Col D.----||-Col. E----||
2. --Event----||Income--||-Expense-||----Total-----||-Is Income?||
3. STARTVAL. ||--------||---------||-----$100-----||-----------||
4. Hamburger ||--------|| $10 ||--*FORMULA 1*-||-----------||
5. Paycheck ||--$20---||---------||--*FORMULA 2*-||-----Y-----||
I thought that the FORMULA 1 would have to look like this:
=IF(E4="Y",(D3+B4),(D3-C4))
Formula 2 would look like this:
=IF(E5="Y",(D4+B5),(D4-C5))
You can see that having to update each cell by 1 depending on if it's income or an expense is inefficient...
I would expect column E to cause the IF function in column D to produce new equations depending on the value in column E, but all I get in Google Sheets is
Formula Parse error

try this formula in D4 cell and drag down:
=IF(E4="Y"; D3+B4; D3-C4)
if that works delete everything in range D4:D and paste this in D4 cell:
=ARRAYFORMULA(IF(LEN(A4:A); IF(E4:E="Y"; D3:D+B4:B; D3:D-C4:C); ))

Related

I am tracking my investments - If column 2 (contains my contribution) is less than column 3 (investment return), return column 1 (date of occurrence)

I have a spreadsheet on Google Sheets that tracks my investment. Based on average returns I have calculated the average return rate over the years.
First column no.1 has a list of dates. Column no.2 has my contribution. Column no.3 has the average return.
I would like to do the following if statement: if(column2<column3)return(column1)
This is so I can see the date my returns become more than my contributions.
This code assumes that column1 is A, column2 is B and column3 is C.
the formula for the IF statement is:
first the thing you want to test
next the return value if true
last the return value if false.
I have set false to return 0, but you might want something else.
=IF($B1<$C1;$A1;0)

Power BI- DAX measure-Table Condition based on the multiple if

I have a 2 tables, Table 1 is "Data" and Table 2 is "Rule". How can I apply multiple if condition based on the table condition in Power BI?
Table-Data-(Column A, B and C is my Raw data)
Column A contain Text (Code)
Column B contain Number (Usage)
Column C contain Text (Usage Unit)
Column D output for usage column
Column E output for usage Unit column
Note: column D and E my output column based on the column A to C
enter image description here
Table 2- Rule-(This is my condition table for usage and usage unit according to the code
enter image description here
Column A contain the following code "MII", "KKR", "CHE" and "RCB" then usage column can not be blanks or 0 and usage unit column must be blanks for the code "MII" and the remaining codes usage unit can be blanks or the usage unit must be match the following two codes "DMK" or BJP".
Column A contain the following code "001", "KXP", "SRH","DEL" and "RRL" then usage column must be blanks and usage unit column must be blanks as well.
Example;
enter image description here
code Usage UsageUnit Usage(Output) Usage unit(Output)
001 0.00 Okay Okay
001 1.00 DMK Not okay Not okay
MII 0.00 BJP Not okay Not Okay
MII 1.00 OKAY OKAY
Additional condition for usage columns has 999 then usage output is "xx".
https://www.dropbox.com/s/cozopedtucklomu/CONDITION%20MATCH.xlsx?dl=0
https://www.dropbox.com/s/k68p2mru6yqob6z/CINDITION-MATCH.pbix?dl=0
You can use SWITCH in your CalculatedColumn/Measure. The first argument is TRUE(), second -> our condition evaluated to true, third output, forth, next condition, fifth, output and so on.
SWITCH (
TRUE(),
'DATA'[Code] in {"MII", "KKR", "CHE", "RCB"} && NOT(ISBLANK('DATA'[USAGE]), "ConditionOuptput",
'DATA'[Code] in {"001", "KXP", "SRH","DEL" ,"RRL"} && ISBLANK('DATA'[USAGE]), "SecondConditionOutput",
"Else goes here"
)

Lookup last value in sheet where other cell contains value

I'm trying to find the last instance of a value in a sheet. The value is an amount of currency, and the condition should be if the type of currency is Income. For example, I have a sheet with
Date Name Amount Type
2019-08-01 Cash on hand 52.52 Income - Allowance
2019-08-02 Cash on hand 33.33 Income - Hourly
and I want to match the latest amount of income (33.33) and display it in another cell.
I've tried something like =INDEX(FILTER(A:A;NOT(ISBLANK(A:A)));ROWS(FILTER(A:A;NOT(ISBLANK(A:A)))) from Get the last non-empty cell in a column in Google Sheets where instead of NOT(ISBLANK()) I tried to put "Income*. I also tried to do a chain of MAX(FILTER()), but I got an error:
FILTER has mismatched range sizes. Expected row count: 999. column count: 1. Actual row count: 1, column count: 1.
Any help would be much appreciated.
=QUERY(A2:D, "select C where D matches 'Incom.*' offset "&COUNTA(
QUERY(A2:D, "select C where D matches 'Incom.*'", 0))-1, 0)

sap hana calculated column check for multiple IDs

i want to create a calculated column, which will show two values: Y or N
2 columns are here important, "VAT-ID" and "CUSTOMER-ID". the calculated column will check if a customer-ID has multiple VAT-IDs. If yes the value "Y" should be displayed, else "N".
for example, the first 5 rows of the customer-id column are:
123456
654321
666666
123456
654321
the first 5 rows of the VAT-id column are:
EE999999999
AA999999999
GG999999999
KK999999999
AA999999999
the first 5 rows of the calculated column should be then:
Y
N
N
Y
N
any Help would be appreciated
Calculated columns don’t allow for aggregations across groups or other than the current row.
What you can do to achieve your goal is to create a separate aggregation node and count distinct VAT-IDs grouped by CUSTOMER-ID.
With this, you can now have a calculated column that checks for VAT-ID-COUNT > 1 and map it to your Y/N values.
As Lars mentioned it is not possible to use a window function within a calculated field on HANA table
But you can use following query to check if VAT number is multiple for a customer or not
select
CustomerId, VATID,
case
when (count(*) over (partition by CustomerId, VATID)) > 1
then 'Y'
else 'N'
end
from CustomerVAT;

Using ArrayFormula for a running total causes a circular reference

See attached Google Sheet for example/sample of my issue. I am trying to use an ARRAYFORMULA() to keep a running total in column C, based on adding the previous row's value in column C with the current row's value in column B. Before I make it an ARRAYFORMULA, it works fine. In column F-H, you can see I tried the array version and get a "circular dependency" error.
The working formula:
=B3+C2 (this is in cell C3)
The non-working formula (with the desired ARRAYFORMULA):
=ArrayFormula(G3:G+H2:H) (this is in cell H3)
My question is, what adjustments can I make to my formula that will allow me to auto-fill this formula down the page as new rows are added (and not populating data for blanks).
Name Days Total Days
Jane 5 6
Tom 2 8
Billy 4 12
Sue 6 18
Sally 1 19
Sample document
=ARRAYFORMULA(IF(B2:B="", ,SUMIF(ROW(B2:B), "<="&ROW(B2:B), B2:B)+1))
demo spreadsheet
if this is what you need ( to always sum total in C column ),
then you don't need arrayformula you can use this simple cell formula (this is C2 formula):
=B2+(If(ISNUMBER(C1), C1, 0))
and spread it down the page, here is the sheet I captured
cheers, kres