Contributor

## IF function without ELSE condition

I am looking at a calculation where I want to have C = IF A > 0 THEN B ELSE DO NOTHING...

DO NOTHING needs to retain previous value on C.

Jairam Kamath
17 REPLIES 17
Certified Master Anaplanner

## Re: IF function without ELSE condition

HI @jairam,

We cannot write a formula without else condition in the IF statement. I would suggest, creating another line item says IF A>0 then B else C. If you want to take the previous period's value you can also say IF A>0 then B else PREVIOUS(C).

I hope it helps!

Regards,
Kavin.
Frequent Contributor

## Re: IF function without ELSE condition

Hi @jairam ,

As @kavinkumar Suggested that you can use previous function to get previous value of C. Please find the below screenshot.

Thanks,

Community Boss

## Re: IF function without ELSE condition

Hi @jairam,

This is possible using Previous function.

Previous Function Takes the Previous value of the same line item.

But your module should have Time as a dimension.

Sorna Raja Prabhu
Certified Master Anaplanner

## Re: IF function without ELSE condition

Are you looking to return the previous value of C as it relates to 'time' or as it relates to 'version'?

Previous time period = IF A >0 THEN B ELSE PREVIOUS(C)

Previous version = IF A > 0 THEN B ELSE PREVIOUSVERSION(C)

Contributor

## Re: IF function without ELSE condition

Hi All,

Thank you for the quick responses. It is my bad I did not frame the question correct. I was working with boolean in my case.

Formula: C = IF A then PREVIOUS(C) ELSE B

Example:

A=FALSE
B=100

Then  -> C = 100

When A = TRUE
2nd Run: C value should remain as 100.
But C is getting ZERO'd out.

Jairam Kamath
Community Boss

## Re: IF function without ELSE condition

Hi @jairam

I have tried to replicate your logic, i came up with few scenarios,let's say

Scenario 1.  your first case A= false, B=100  then C should be 100, this working perfectly.

Scenario 2: Here my month started from Jan 20 so we don't have any previous value for C then in this case when A= True , B= 100 then all C = 0.

I think you may have encounter with this case.

Scenario 3: here A= True for Jan but false for Feb , B=100 then you can get the value for C except Jan 20

Hope this helps!

Thanks

Akhtar

Contributor

## Re: IF function without ELSE condition

Hi All,

When I mean Previous, I meant Previous value in the same cell. (Not the previous period value).

Please check the below flow of data:

 Scenario-1 Jan-20 Feb-20 Mar-20 Apr-20 A FALSE FALSE FALSE FALSE B 100 100 100 100 C 100 100 100 100

Now setting A to TRUE:

 Scenario-2 Jan-20 Feb-20 Mar-20 Apr-20 A TRUE FALSE FALSE FALSE B 100 100 100 100 C 100 100 100 100

Now changing Values in B. The C should retain 100 (previous value in same cell). - Ignore the calculated value.

 Scenario-3 Jan-20 Feb-20 Mar-20 Apr-20 A TRUE FALSE FALSE FALSE B 200 200 200 200 C 100 200 200 200

Regards,

Jairam

Jairam Kamath
Certified Master Anaplanner

## Re: IF function without ELSE condition

Lets not over complicate things! Why don't you create another line item D and say IF A then B else C as I suggested in my earlier post? Do you have any size constrain?

You cannot write a formula to retrieve the previous value in a cell.

Regards,
Kavin.
Community Boss

## Re: IF function without ELSE condition

Hi @jairam,

As you mentioned Logic earlier: IF A then Previous(C) else B

 Scenario-3 Jan-20 Feb-20 Mar-20 Apr-20 A TRUE FALSE FALSE FALSE B 200 200 200 200 C 100 200 200 200

Your Previous question : "Now changing Values in B. The C should retain 100 (previous value in same cell). - Ignore the calculated value."

and i didn't understand how and why C should retain 100.

can you explain in detail....?

Sorna Raja Prabhu