on 09-04-2015 1:04 AM
I'm new to Lumira and following the typical CR2013 formula text, trying to create a simple formula that will create a Calculated Dimension from a SQL column {ParkingDuration] :
if {ParkingDuration} < 60 then "1 Hour" else
if {ParkingDuration} > 120 and < 180 then "3 Hours" else
if {ParkingDuration} > 180 and < 240 then "4 Hours" else
if {ParkingDuration} > 240 and < 300 then "5 Hours" else
if {ParkingDuration} > 300 and < 360 then "6 Hours" else
if {ParkingDuration} > 360 and < 1440 then "7-24 Hours" else "> 24Hrs."
I keep getting "No viable alternative at "<". Try rewriting the formula.
i apologize in advance if I posted the question in the wrong forum.
Much Appreciated.
Hi John,
Correct syntax is as follows. Notice that I modified slightly the logic so as to get the desired output (there were some gaps not considered in your original ranges, for instance 60 - 120, exactly 180, exactly 240, etc).
I also assumed 60 minutes is still considered as "1 hour", 120 still counts as "2 hours", etc.
if {ParkingDuration} <= 60 then "1 Hour" else
if {ParkingDuration} > 60 and {ParkingDuration} <= 120 then "2 Hours" else
if {ParkingDuration} > 120 and {ParkingDuration} <= 180 then "3 Hours" else
if {ParkingDuration} > 180 and {ParkingDuration} <= 240 then "4 Hours" else
if {ParkingDuration} > 240 and {ParkingDuration} <= 300 then "5 Hours" else
if {ParkingDuration} > 300 and {ParkingDuration} <= 360 then "6 Hours" else
if {ParkingDuration} > 360 and {ParkingDuration} <= 1440 then "7-24 Hours" else "> 24Hrs."
There are more simple formulas to achieve the same results, but for the moment this one will do the job.
Regards,
Fernando
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here's a much simpler formula
if {ParkingDuration} <= 360 then Concatenate(Truncate( {ParkingDuration} / 60 + 1, 0), " Hour(s)") else if {ParkingDuration} <= 1440 then "7-24 Hours" else "> 24 Hrs."
I hope one of these two options correctly answers your question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're welcome John. You can find a Functions Reference on the Desktop Edition User Guide. Currently, the most recent version is 1.28. Refer to page 75. I'm attaching the pdf download link.
http://help.sap.com/businessobject/product_guides/vi01/en/lum_128_user_en.pdf
Another resource which might be helpful is
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.