BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
IgorR
Quartz | Level 8

Hi,

I'm trying to make the following code to be shorter:

	If Period = 40 Then Do;
			If Years > 20 and Years < 30 Then
				Effect_on_Guarantee = 1;
			Else Effect_on_Guarantee = Lapse_Multipliers;
		End;
	Else Effect_on_Guarantee = Lapse_Multipliers;

To achieve this I'm trying to use IFN function like this:

IFN(a.Period = 40, IFN((a.Period  > 20 and a.Period < 30),1, Lapse_Multipliers),Lapse_Multipliers) As Effect_on_Guarantee

In This way IFN doesn't return any error or warning but doesn't the work as along version of code does.

Where is a mistake?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@IgorR wrote:

In This way IFN doesn't return any error or warning but doesn't the work as along version of code does.

Where is a mistake?


You have NOT told us what is wrong. Saying it doesn't work gives us no useful information. What do you see that is wrong?

 

Why do you switch from a variable named YEAR to a variable named PERIOD? Could that be the problem?

--
Paige Miller

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

Why would you want to convert readable code into a function call?

If it is so you add it to an SQL statement then use CASE clause.

case when (Period = 40) then
  case when (Years > 20 and Years < 30) then 1 else Lapse_Multipliers end
  else Lapse_Multipliers
end

If you want to reduce the LOGIC of the test then do:

case when ((Period = 40) and (Years > 20 and Years < 30)) then 1 
  else Lapse_Multipliers
end

 

PaigeMiller
Diamond | Level 26

@IgorR wrote:

In This way IFN doesn't return any error or warning but doesn't the work as along version of code does.

Where is a mistake?


You have NOT told us what is wrong. Saying it doesn't work gives us no useful information. What do you see that is wrong?

 

Why do you switch from a variable named YEAR to a variable named PERIOD? Could that be the problem?

--
Paige Miller
IgorR
Quartz | Level 8
Oh, Thank you!
What a silly mistake.
The problem indeed in switching Years to Period.
Now I fixed it and it works.