Formula if/then/else

Hello,
I am a basic Crystal Report designer and need help with a formula.  I need to check 5 different fields and return a specific test if the field data does not equal zero. So here it goes below. I used "totext" because the value in the fields are a number either 0 or some other number so it does not matter what the # is as long as it does not = 0 I  need the following values.  I will then need to insert a single column in the report.
When I try what I have below, all that's being returned is "Services" so I'm assuming it's not checking the other fields.  Assistance is appreciated.
if totext ({BP_Daily_Item_Report.OBJ_B_SRV_THIS_REQ}) <> "0" then "Services" else
if totext ({BP_Daily_Item_Report.OBJ_B_COM_THIS_REQ}) <> "0" then "Commercial"  else
if totext ({BP_Daily_Item_Report.OBJ_B_CDC_THIS_REQ}) <> "0" then "CDC" else
if totext ({BP_Daily_Item_Report.OBJ_C_SYS_THIS_REQ}) <> "0" then "Systems"
Thanks.

Thank you both.  Using that formula, I did get an error "the keyword then is missing"
({BP_Daily_Item_Report.OBJ_B_SRV_THIS_REQ},"#") "0" then "Services"
So I modified my original forumla by removing totext and the "0" then is said "must be a number. I then removed the " " from around the 0 to what is below and that worked
if ({BP_Approved_Requests.OBJ_B_SRV_THIS_REQ}) <> 0 then "Services" else
if ({BP_Approved_Requests.OBJ_B_COM_THIS_REQ}) <> 0 then "Commercial" else
Thanks.

Similar Messages

  • Formula If/Then/Else question

    Hello all,
      I am using the following formula to read one value (valuation price), and if it = 0, then display the value of another field (moving price), if <> 0, then display that field (valuation price). 
    ( 'Valuation Price' == 0 ) * 'Moving Price' + ( 'Valuation Price' <> 0 ) * 'Valuation Price'
    However, only the first part of the evaluation returns a value, ie only the rows that have a valuation price =0.  If I reverse the order, it does the same thing, almost like it won't evaluate the "else" part of the evaluation.
    If anyone see's something obvious I would appreciate your input.  I have read the help file and done some searching but have found nothing relevant.  
    Thanks for any help
    Bill Coombs

    Bill, change your formula to
    ( NODIM('Valuation Price')== 0 ) * NODIM('Moving Price') + ( NODIM('Valuation Price') <> 0 ) * NODIM('Valuation Price')
    Hope this works.
    -KRREDDY

  • Problem in If-Then-Else formula in report

    Hello guys!
    I use an If-Then-Else statement in a Calculated Key Figure (Cf. <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/23/17f13a2f160f28e10000000a114084/content.htm">Conditional Calculations</a> ) and it works great with basic calculations.
    I have a query (done in BI 7.0) where I display, for each calendar months (via 0CALMONTH), the usage (stored in a normal key figure in hours) of several products.
    I need to take into account only the products that have been used for at least 60% of the time of the highest product for each month. I a single product, for a month, has been used less than 60% of the highest one, it should be considered as not being used at all (so the calculated usage would be = 0), otherwise, its usage is counted as normal.
    In order to achieve this, I thought I would display the normal usage (the regular key figure) in column A, a calculated key figure that determines the MAXimum usage for each month in column B (which should be the same for all products) and another calculated key figure that displays the result of the If-Then-Else statement in column C.
    In rows, I have 0CALMONTH and the products.
    HOWEVER, when I do this, the result is incorrect. This is probably because to determine the MAX usage, I use a local calculation option, which displays the correct maximum usage on each row but it's not correct when used somewhere else.
    <b>MY QUESTION IS: HOW can I display the maximum usage for a month on all rows without using the calculation option (and therefore would be correctly used by the If-Then-Else statement. I tried an aggregation exception but it doesn't really work (it works only on the total, but I need to do the calculation on each individual row).</b>
    <u><b>Any useful comment will be greatly appreciated </b></u>
    Thanks in advance!

    Hi Francal ,
    Have you tried it . The constant selection will work if you have defined the calculated key figure correctly i.e. Aggreagtiomn "Max" with "product" as ref characteristic. Then you have to use this calculated key figure in your query , restrict it by "product" and make it a constant selection.
    The calculated key figure it self  will bring the highest usage for Month + product + ( any other characteristic you have in query ) but this will only apply to result . If you use constant seelction on top of it it will make sure that you see same value for all product for a particular month( and other characteristic combinations if you have ).
    I have built similar queries and it works . By the way which versions of backend and frontend you have ??
    Regards
    Sanjay

  • Query if-then-else logic with calculation

    Hello,
    I want to calculate within a BEX-formula.
    I have two key-figures:
    - Quantity
    - Value
    The logic should be like this:
    IF Value > 0 THEN Value / Quantity ELSE 0
    ( / means: divided)
    How can I reach this?
    The URL
    http://help.sap.com/saphelp_nw70ehp1/helpdata/de/e3/e60138fede083de10000009b38f8cf/frameset.htm
    does not help me.
    Thanks for your help,
    Thomas

    That is the way to perform if then else...
    As long as boolean operations returns 0 or 1 you must play with that in order to get the desired result.
    In case you have DIV problems you can use this operator:
    NDIV0 (x): Is equal to 0 with division by 0, otherwise x.
       NDIV(<Expression>)
    Delivers 0 if the expression named in <Expression> gives a division by 0 in
    the calculation. Otherwise, the result is the value of the expression.
    Is used to
      - Avoid the output of an error message
      - Continue calculating with a defined result
    Please give an example if I am missing something.
    Regards,
    Sebastian,.

  • How to write Boolean function (If Then Else)?

    Hi all,
    I have a logic to write in the query. It is:
    If (A = 0 and B = 0)
    Then 0
    Else
            If (A = 0 and B > 0)
            Then 100
            Else
                   A/B  (we want to show %)
    How to use boolean function to write this Netted If Else statement? Thank you in advance!

    Hi
    If (A = 0 and B = 0)
    Then 0
    Else
    If (A = 0 and B > 0)
    Then 100
    Else
    A/B (we want to show %)
    1. create a formula in the query designer. and use this formula for if - else
    ( ( (A==0) AND (B==0) ) * 0) +  ( ( a==0 ) AND (B >0 ) * 100 + (A/B*100) )
    : denotes THEN
    + : denotes ELSE
    See if this works.
    Assign points if helpfull
    From
    ManesH

  • How to write Boolean function (If Then Else) For Date Caluclation.

    Dear All,
    I have a scenario where i need to calculate Position time hold by an employee in an organisation.
    I have 2 date Char ( DATE FROM & DATE TO), the problem is that is , If an employee is having
    2/3 position in an organisation its current position End Date is always 31.12.999 as its End date is
    not know. For previous position End Date is maintained.
    My requirement is to calculate Position hold time including Current position.
    Can it be done directly in formula variable with If Then Else condition.
    or i need to write user exit if its exit,
    please guide me for ABAP Code.
    Thanks V V much.
    Regards,

    Hi,
    Following options are available for you:
    1. Is the valid to, valid from dates available as a result of standard time dependency of navigational attributes? if yes , you can not use them in calculations, in such case you may have to write a full fledged routine at formula variable, using uxer exit.
    2. Another simple method, that i would suggest would be using temporal joins (infoSets), that precisely fits you case.
    Helpful links:
    About Infosets:
    [http://help.sap.com/saphelp_nw70/helpdata/EN/ed/084e3ce0f9fe3fe10000000a114084/frameset.htm]
    About Temporal joins:
    [http://help.sap.com/saphelp_nw70/helpdata/EN/11/723c3b35703079e10000000a114084/frameset.htm]
    Hope this helps.
    Cheers,
    Sumit

  • Inserting a 'null' value in an IF THEN ELSE statement

    Greetings,
    I'm using Business Object webi XiR3
    I'd like to return a 'null' value in certain cases for an IF THEN ELSE statement.  Depending on if I format the field as a text or a number, I can return blanks ("") and zeros (0).  However, what I really need to do is leave the field / column formatted as a number and return a 'null' value.  You can see the variable below ... this will return a blank but the column is text.
    Suggestions?
    thanks.
    variable:
    =If([Comp Rate Mid] = 0 And( ([Market Rate 50th].085) - [Annual Total Targeted Comp] >=0) ; ([Market Rate 50th]0.85) - [Annual Total Targeted Comp]; If([Comp Rate Mid] <> 0 And( ([Comp Rate Mid] 0.85) - [Annual Total Targeted Comp] >=0) ; ([Comp Rate Mid]0.85) - [Annual Total Targeted Comp];""))

    I don't think this is possible using a formula, as formulas deal with content, and images can be placed in cells only as 'image fill', which is Format, rather than Content.
    Might be possible using an AppleScript, but I'm not the person to advise you on that.
    Regards,
    Barry

  • Sum function within if/then/else (xdofx:if)

    I'm attempting to display a total at a particular group within my report. This total is conditional and should choose to display a placeholder value or the sum of another placeholder value (in a child group).
    I have been able to vary my output based on the value I want to check: FIXED_QUOTE_FLAG - I have the if/then/else working in a simplified fashion
    I can display literals and some placeholders correctlly eg. print a literal value of 00110011 or the value of placeholder QUOTED_PRICE
    I can also display a calculated placeholder, using sum within the group I am concerned with: sum (current-group()/ACTIVITY_CHRG)
    But when I try to get everythign working together ...
    I cannot get the sum to work inside the if/then/else condition. The result is NULL (blank in HTML output).
    The following is the snippet which is not working correctly:
    <?xdofx:if FIXED_QUOTE_FLAG = 'Y' then QUOTED_PRICE else sum (current-group()/ACTIVITY_CHRG) end if?>
    Message was edited by:
    gareth_adamson

    To answer you first question, perhaps sum is not a supported function in the xdofx namespace. It's annoying when this problem comes up because xdofx namespace seems to be the only way to do if then else clauses. I'm not entirely certain on the above, but you could resort to using BI Publisher's built-in if statement.
    For your problem, something like this:
    <?if: FIXED_QUOTE_FLAG='Y'?>
    QUOTED_PRICE
    <?end if?>
    <?if: FIXED_QUOTE_FLAG!='Y'?>
    <?sum(current-group()/ACTIVITY_CHRG)?>
    <?end if?>
    EDIT:
    There is a way to do if else without xdofx namespace. It is done with <?choose:?> <?when:?> and <?otherwise:?> tags. Here is example syntax copied from Tim Dexter's blog:
    <?choose:?>
    <?when:count(TRX_NUMBER) > 0?>
    Invoice Table
    <?end when?>
    <?otherwise:?>
    No Data Found
    <?end otherwise?>
    <?end choose?>
    To answer the second question about a running total, you will need to use the <?xdoxslt:set_variable($_XDOCTX,'var_name',var_value)?> and the <?xdoxslt:get_variable($_XDOCTX,'var_name')?>. This method of working with variables is the only method that allows you to update a variable. This makes it good for running totals. Consult the official user guide under "Creating an RTF Template" the section about using variables and calculating running totals.
    So, in your problem, once you get the first part working, you will have to add that value to your running total. It will look something like this:
    <?xdoxslt:set_variable($_XDOCTX,'running_total',xdoxslt:get_variable($_XDOCTX,'running_total') + conditional_value)?>
    Remember to initialize the running total to zero! Hope this helps.
    Thanks,
    Matt Soukup
    Message was edited by:
    Matt Soukup

  • Problem with IF THEN ELSE in RTF template

    HI ALL,
    I have two layouts in the RTF template. Based on the parameter value it has to show the value.
    For example if P_State='United States' then first layout should come. else second one should come.
    I tried to use the IF Then else logic through the form field but i am getting error.
    Please help on this to get it.
    Regards
    Boopathi

    You can do that.
    i guess, the syntax you are using is wrong.
    please refer documentation or this forum for choose:
    Use choose statement. it s better.
    Or send me the template to my id in my profile. or upload it here http://apps2fusion.com/forums/viewforum.php?f=60

  • If Then Else Statement in SAP R/3 BW

    Hi,
    Does anyone know how to create an If Then Else statement in BEX?
    Thanks,
    Mounika.

    Hi mounika,
    do this way
    If 'material number' > 0.
    rslt = 'enter into table'.
    else.
    rslt = 15.
    endif.
    A True condition always evaluates to 1, a False condition evaluates to 0.
    for more quieries in bw ..pls go through  the link
    http://sap.ittoolbox.com/groups/technical-functional/sap-bw
    pls reward if helps,
    regards.

  • Select in CASE statement or in IF-THEN-ELSE

    I have been struggling for a week with a problem and still can't solve the way I want.
    Given four text fields in page : p1_name, p1_place_name, p1_place_number and p1_place_init_letter - where user types text and press 'Search' button to see the results.
    p1_name finds results in table EMPLOYEES
    p1_place_name, p1_place_number and p1_place_init_letter find results in table PLACES
    the two tables are linked by id_place field
    I would like reports to be shown depending on search results:
    - if p1_name exists and (p1_place_name and p1_place_number and p1_place_init_letter) exist AND EMPLOYEES.id_place = PLACES.id_place then a single report shows only employee row
    - if p1_name exists and (p1_place_name and p1_place_number and p1_place_init_letter) exist AND EMPLOYEES.id_place # PLACES.id_place then two reports showing 1) employees with name = :p1_name and 2) places with name, number and init_letter = :p1_.....
    - if p1_name not exists and (p1_place_name and p1_place_number and p1_place_init_letter) exist then a message with 'NO EMPLOYEE' and report shows only places where name, number and init_letter = :p1_.....
    - if p1_name exists and (p1_place_name and p1_place_number and p1_place_init_letter) not exist then report shows only employee row where name = :p1_name and message with 'NO PLACE'
    - if p1_name not exists and (p1_place_name and p1_place_number and p1_place_init_letter) not exist then messages 'NO EMPLOYEE' and 'NO PLACE'
    I do NOT know if it is possible, and if it is, then what do I have to use : IF - THEN - ELSE or CASE ?
    I tried to build HTML report region conditionally shown for each situation, but they do not work the way I want.
    Could you please help me ?
    Thank you in advance !

    Agree with Dan. Use a dedicated report region for a unique query. Use a rendering condition to determine if that reporting region must be rendered (i.e. whether or not that reporting query must be executed ).
    The alternative is creating a function that constructs the SQL query dynamically, based on the user supplied values for page items. Use the function as the source for the reporting region, instead of a SQL statement. (this is similar to creating a ref cursor for a client, minus the actual step to create the ref cursor - instead the source SQL for that ref cursor is returned).
    Also consider asking your Apex questions in the dedicated Apex forum on OTN.

  • If-then-else in a select statement

    hi, is it possible to make a if-then-else in a select query, something like:
    select name, age, if(sex=f,1,2) as my_columnn from table1;
    thx.

    Hallo,
    yes it is possible:
    1. with decode
    select name, decode(sex, 'f',1,2) as your_column from table1;
    2. with case
    select name, case when sex='f' THEN 1 ELSE 2 END) as your_column from table1;
    Regards
    Dmytro

  • Problem with if-then-else using BI Answers dataset

    Hi, I'm having issues using the if-then-else logic with a BI Answers dataset. I'm running two versions of a report - one that access the SH schema tables directly, and one that uses a BI Answers dataset based on the SH schema.
    My problem is with the if-then-else operator. It works fine against the relational tables when I use the following syntax:
    <?xdofx:if CUST_GENDER = 'M' then 'Mr.' else 'Ms.' end if?>
    However, when I go against a BI Answers report, the name of the field changes from CUST_GENDER to Customers._Cust_Gender_. If I make an exact find and replace on the if-then-else code, it doesn't work (nothing at all displays)
    <?xdofx:if Customers._Cust_Gender_ = 'M' then 'Mr.' else 'Ms.' end if?>
    Can anyone help?
    Thanks,
    Scott

    Is it possible that any of the fields have null values?  If so, see my blog post about null handling in Crystal for more information:  What is Null and Why is it Important for Crystal Reports | SAP BI BLOG
    -Dell

  • Java If/Then/Else Statement

    Hello,
    Just wondering if it is possible to call one java file from within another.
    I'm thining wiht an if.then/else statement similar to
    If x==true
    then run file1.java
    else run file2.java
    any examples of this, or if it is even possible would be appreciated.

    This is something like what I would do.
    public class FileRunner {
        public static void main(String [] args) {
            if ( args[0].equals("file1") {
                File1 file1 = new File1();
                file1.init() //method you define in File1 that runs everything that would've been in the File1's main method
            } else if (args[0].equals("file2") {
                File2 file2 = new File2();
                file2.init() //method you define in file2 that runs everything that would've been in the File2's main method
            } else {
                System.err.println("Invalid argument");
                System.exit(1);
    java.exe FileRunner.class file1
    java.exe FileRunner.class file2The other method is to start a new jvm from within java, but that gives you less control than this imo.

  • Nested if-then-else with double condition

    Hi everybody, I tried to see on the forum how to build a complex if-then-else statement....but I didn't still find an answer
    So, I'll explain my situation:
    First I have to check if the field PROJ_DT_TO is null or not and then the language parameter:
    1. if the field PROJ_DT_TO IS NULL then I have to check the language parameter:
    a) if this last one is equal to 'English' I want to write inside my template 'Today',
    b) if instead is equal to 'Greek' I want to write 'Σήμερα'
    2. else if the field PROJ_DT_TO IS NOT NULL, again, I have to check the language parameter:
    a) if this last one is equal to 'English' I have to write <?format-date:PROJ_DT_TO;'MMMM yyyy'?>
    b) if instead is equal to 'Greek' I have to write <?format-date-and-calendar:PROJ_DT_FR;‘MMMM yyyy’;'GREGORIAN';'Europe/Athens'?>
    I used the following syntax...but it didn't work...
    <?choose@inlines:?>
    <?when@inlines:PROJ_DT_TO=''?>
    <?xdofx:if $p_language = 'Ελληνικά' then 'Σήμερα' else if $p_language = 'Αγγλικά' then 'Today' end if?><?end when?>
    <?otherwise@inlines:?>
    <?xdofx:if $p_language = 'Ελληνικά' then <?format-date-and-calendar:PROJ_DT_FR;‘MMMM yyyy’;'GREGORIAN';'Europe/Athens'?> else if $p_language = 'Αγγλικά' then <?format-date:PROJ_DT_TO;'MMMM yyyy'?> end if?>
    <?end otherwise?>
    <?end choose?>
    The first piece, until the first <?end when?> instruction works....it's the <?otherwise@inlines:?> and the rest which doesn't work.....
    If, instead, I use (without reaching my goal):
    <?choose@inlines:?>
    <?when@inlines:PROJ_DT_TO=''?><?xdofx:if $p_language = 'Ελληνικά' then 'Σήμερα' else if $p_language = 'Αγγλικά' then 'Today' end if?><?end when?>
    <?otherwise@inlines:?>
    <?format-date:PROJ_DT_TO;'MMMM yyyy'?><?end otherwise?>
    <?end choose?>
    I see the date PROJ_DT_TO even if always in the date format 'MMMM yyyy'
    Anybody knows how can I rewrite my statement in order to reach the if-then-else situation I metioned above ?
    Thanks in advance
    Best Regards
    Alex

    Hi Vetsrini, thaks for your answer and your hint !!
    I tried your code, but without the command 'when@inlines' doesn't work...
    So I tried this :
    <?choose@inlines:?>
    <?when@inlines:PROJ_DT_TO=''?>
    <?xdofx:if $p_language = 'Ελληνικά' then 'Σήμερα' else if $p_language = 'Αγγλικά' then 'Today' end if?>
    <?end when?>
    <?otherwise@inlines:?>
    <?format-date:PROJ_DT_TO;'MMMM yyyy'?>
    <?end otherwise?>
    <?end choose?>
    and It works..
    But, look at this ! I discovered on the manual that inside the Preferences it's possible to set the Report Locale with the language you want.....and if I set my Report Locale in Greek, using the code above I correctly see all dates in Greek....but ALWAYS !!
    I need to see dates in Greek or English dinamically according to the value of the parameter p_language passed inside the template at the beginnig (<?param@begin:p_language?>).
    Even if inside the code there is the double condition ($planguage = 'Ελληνικά' or $p_language = 'Αγγλικά') for the two cases PROJ_DT_TO='' or PROJ_DT_TO !='', I see ALWAYS dates in the language set inside the Locale Report....
    Is there a way to manipulate the Report Locale Setting and make it dinamic ?
    Thanks in advance
    Alex
    So this preference is static, even if inside my report I have the parameter p_language I can see the data and headings with

Maybe you are looking for

  • Lots of free space that I cant use 5c

    Hi, I have a iphone 5c, and I can only put a small amount of music on it. There is months of music on my computer, but when I 'autofill' it only puts about a hundred songs on. Afterwards there is about 5gB of free space on my phone. I also cant updat

  • Show File name as download link in a report

    Hi people, In an application (APEX 4.2.1) I have a reprot whith a file donwload column. I implemented the download as a BLOB column with "DOWNLOAD" as Format Mask. This works fine, I can download attachments, no probs so far. However, I want the Down

  • Marking Multiple Videos As TV Shows

    When I fired up iTunes 7, I saw that there was an option to change individual movies to TV Shows, but since I have whole seasons, it would be very tedious to do this for all my TV Shows. The option to change to TV Show is only available on the video

  • Oracle User Guides in Foreign Languages

    Does anyone know how to obtain Oracle User Guides a foreign language? We are internationally based. I've had no success on Metalink. Appreciate any guidance, Regards, Kim Brennan [email protected]

  • How to nudge in very small increments

    Hi all. Have recently switched from Quark XPress to inDesign CC2014. How do you nudge/move an object in fine increments? In Quark it was option + arrow keys, and option command + arrow keys to move in even finer increments.