IF function without ELSE condition

Highlighted
Occasional 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.

jairamkamath
17 REPLIES 17
Highlighted
Master Anaplanner/Community Boss

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.
Highlighted
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.

 

naushad786_0-1584511247855.png

 

Thanks,

Naushad

 

 

Highlighted
Super Contributor

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.

 

 

 

Capture5.JPG

Sorna Raja Prabhu
Highlighted
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)

Highlighted
Occasional 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.

 

 

jairamkamath
Highlighted
Super Contributor

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.

 

Screenshot_153.png

 

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.

Screenshot_154.png

 

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

 Screenshot_155.png

 

Hope this helps!

Thanks

Akhtar

Highlighted
Occasional 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-20Feb-20Mar-20Apr-20
AFALSEFALSEFALSEFALSE
B100100100100
C100100100100
     

 

Now setting A to TRUE:

Scenario-2 Jan-20Feb-20Mar-20Apr-20
ATRUEFALSEFALSEFALSE
B100100100100
C100100100100

 

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

Scenario-3 Jan-20Feb-20Mar-20Apr-20
ATRUEFALSEFALSEFALSE
B200200200200
C100200200200

 

 

Thank you in advance!

 

Regards,

Jairam

jairamkamath
Highlighted
Master Anaplanner/Community Boss

Re: IF function without ELSE condition

@jairam,

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.
Highlighted
Super Contributor

Re: IF function without ELSE condition

Hi @jairam,

 

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

 

and considering your scenario 3

 

Scenario-3 Jan-20Feb-20Mar-20Apr-20
ATRUEFALSEFALSEFALSE
B200200200200
C100200200200

 

 

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