Using Variables with IF


#1

Hi,

This is a simple one .

I am picking up someone else’s code and need to clarify a point.

I have the following measure that is using Variables and my question is based around the IF that is in Bold.

Does the IF check the AvailableTime _PER to see if it is greater than 0 or just check whether there is something in the Variable? If I want to check whether it is greater than 0 do I need to add the > 0. I have never seen a measure written in this way and have not been available to find an explanation.

Availability_PER:=VAR
AvailableTime_PER = [AvailableTime_PER]
VAR
AvailableTime_PERPlusDowntimeUnPlanned_PER = [AvailableTime_PER] + [DowntimeUnPlanned_PER]
RETURN

	   **IF (**

** AvailableTime_PER,**
DIVIDE(AvailableTime_PER, AvailableTime_PERPlusDowntimeUnPlanned_PER),
BLANK()
)
Thanks

Chris


#2

I’m not exactly sure what this measure is - AvailableTime_Per

But I would presume this has to be a boolean results TRUE/FALSE. If not this will will likely through an error.

If it returns TRUE or FALSE then I would say it’s fine.

What happens when you do either?


#3

It is returning a time allocated in hours. Just seems bizarre. A Lot of the code uses the same technique and there are no true or false options. It does the calculation and returns a number but I just don’t know what it is checking.


#4

Interesting so it returns a result for you even if there is no check?

All I can imagine that being is if there is say no result. Then it must return a FALSE.

I wouldn’t recommend this, just update it so it’s a intuitive as possible. (I’m sure you’ve already done)


#5

Cheers Sam

I have done, just very strange.

Have a goodun

Chris