Formula Value Creation

Hi All,
I want to create a final value based on the formula created from the table:
STEP
OPERATOR
VARIABLE
VAR_VALUE
1
A
10
2
0
B
20
3
4
C
30
5
D
40
6
7
0
E
50
8
-0
9
F
60
10
G
70
11
The Formula that i am creating is
SELECT LISTAGG(operator || variable)       
       WITHIN GROUP(ORDER BY step) formula
  FROM bharat_formula;
The result is A+B*(C/D)+E-(F*G)
and the formula with value that i am creating is :
SELECT LISTAGG(operator || var_value)
       WITHIN GROUP(ORDER BY step) formula
  FROM bharat_formula;
and the result is 10+20*(30/40)+50-(60*70)
Now i want to formulate the formula as 10+20*(30/40)+50-(60*70) and get the calculated value of the formula as -4125.
Can any body please help me in how to create the formula and calculate the value in a single statement?

May be
SQL> with t
  2  as
  3  (
  4  select 01 step, ''  operator, 'A' variable, 10    var_value from dual union all
  5  select 02 step, '0' operator, 'B' variable, 20    var_value from dual union all
  6  select 03 step, '*' operator, ''  variable, null  var_value from dual union all
  7  select 04 step, '(' operator, 'C' variable, 30    var_value from dual union all
  8  select 05 step, '/' operator, 'D' variable, 40    var_value from dual union all
  9  select 06 step, ')' operator, ''  variable, null  var_value from dual union all
10  select 07 step, '0' operator, 'E' variable, 50    var_value from dual union all
11  select 08 step, '-0'operator, ''  variable, null  var_value from dual union all
12  select 09 step, '(' operator, 'F' variable, 60    var_value from dual union all
13  select 10 step, '*' operator, 'G' variable, 70    var_value from dual union all
14  select 11 step, ')' operator, ''  variable, null  var_value from dual
15  )
16  select replace(sys_connect_by_path(str, ','), ',') formula
17       , xmltype
18         (
19            dbms_xmlgen.getxml
20            (
21               'select ' || replace(sys_connect_by_path(str, ','), ',') ||
22               ' val from dual'
23            )
24         ).extract('/ROWSET/ROW/VAL/text()') val
25    from (
26            select step
27                 , ' '
28                   || decode(operator, null, ' ', '0', '+', '-0', '-', operator)
29                   || ' '
30                   || to_char(var_value) str
31              from t
32         )
33   where connect_by_isleaf = 1
34   start with step = 1
35  connect by step = prior step + 1;
FORMULA                                            VAL
   10 + 20 *  ( 30 / 40 )  + 50 -  ( 60 * 70 )     -4125
SQL>

Similar Messages

  • How can we remove the commas from the Formula value in SAP BW BEx query

    Hi All,
    How can we remove the commas from the Formula value in SAP BW BEx query
    We are using the formula replacing with characteristic.The characteristic value needs to be display as number with out commas.
    Regards
    Venkat.

    Do you want to remove the commas when you run the query on Bex Web or in RSRT?
    Regards

  • Is it possible to pass a formula value from a sub-report to a main report

    Hi there,
    Im trying to pass a formula value from a Sub-report back upto into my Main report but the value doesnt seem to be getting passed up. Ive tried it the other way around, that is, passing a value from the main report to the sub-report and that works fine.
    Below is an example of what I am trying to do but it is not working. In my sub-report Ive declared a formula variable as,
    formula name=main_subIntRatePageCount
    Shared NumberVar subIntRatePageCount := TotalPageCount;
    and in the Main report Ive declared the formula variable as,
    formula name=subIntRatePageCount
    Shared NumberVar subIntRatePageCount;
    subIntRatePageCount;
    I want the value assigned to "subIntRatePageCount" in my Sub-Report to be available to my Main report.
    The problem I am trying to solve is that the sub-report is spilling over onto two pages, and I need a way of updating the page display on the main report to reflect this. The page display is of format, "displaying page 1 of  3", but its not taking into account the extra page produced by the sub-report, so it should say "displaying page 1 of 4".

    Also thanks Raghavendra, Asha,
    I've tried adding the "whileprintingrecords" statement but that doesnt seem to make any difference.
    I notice that the subReport is being called from my the GroupFooter section of the main report, and I am trying to reference the variable in the main repot in the Page Footer section. Could it be that the variable hasnt been calculated in the Page Footer by the time I calculate it in sub-Report? I thought Crystal Reports does at least 5 passes over the report evaluating all the formulas before it prints the report?
    The problem Im trying to solve is I need to know how many pages my report will have before its completed, so that i can print the statement "displaying page 1 of X", and X is currently not being calculated correctly because the sub-report is printing onto 2 pages and not 1 so the report thinks I have 1 of X pages and not X+1.
    Regards
    Robert.

  • Services formula value in contract release order

    Hi
    We have a quantity contract with services, the services contain a formula ABC to determine quantity. After selecting the service in the contract release order the full contract quantity is imported resulting in an error message.
    Is there a specific user exit or other method to default the service formula values ABC to 111 after selecting the service in the contract release order?
    thanks

    Anyone any ideas? is there a user exit/enhancement or could a user parameter work?
    Any guidance most appreciated.
    Adrian

  • How to group rows based on a formula value

    Hi experts,
    I have a query that returns a a char row (country) and a couple of columns, "Duration of Process in days" and "Counter of nº process done", each a calculated formula KF .
    What I would like is to group the results based on formula KF1 results ""Duration of Process in days".
    For example: from this query result
    Country  -   Duration of Process in Days  -   Counter of nº process done
    ES                      1                                         3
    PT                      3                                         2
    UK                      4                                         3
    IT                       1                                          5
    US                      6                                         2
    FR                      1                                         3
    DE                      4                                         5
    get the following: aggregated by all possible formula values "Duration of Process in Days"
    Duration of Process in Days  -   Counter of nª process
                    1                                       11   (353)
                    3                                         2
                    4                                         8    (3+5)
                    6                                         2
    Is this possible??
    Thanks in advance for your help,
    Best regards,
    Enric

    Hi Vikram,
    my problem is that the "Duration in days" cannot be a characteristic derived in the loading process, as its value depends (is calculated) based on several user's selections done in the variable pop-up screen when executing the report.
    Thanks again for your reply.
    Enric

  • Transaparent partition formula value not reflect in trgt cube

    Hi All
    I created transaparent partition data is reflecting in the trgt cube but we are calculating member formula for srce cube that values are not reflectin in the trgrt cube I excute design aggregation for srce db still its not reflecting the value s of calculated member, Any help would be appriciated.;
    thanks

    Tanku
    we are using formula in that formula we are using thre dimension crossing
    1 flow
    2 indicator
    3 period
    I am patitioning @idescndents(2009) its not showing
    second i tried this @idescndents(2009) @ idescendents(indicator)
    third i tried this also @idescndents(2009) @ idescendents(indicator)@idescendents(flow)
    we have the formula for flow dimension
    srce and trgt have the all are same dimns , evrything is same , but its not reflecting int to trgt
    plz help on this formula value is it reflect in trgt????
    Thanks

  • Description for Formula Values in Structure

    Hello All,
    I want to change the description of the formula values in my Structure (i want to add the Month that is used in the formula to the description so that the description becomes more dynamic). Can any one of you please suggest a way. This is required quickly so please respond ASAP and ALSO LET ME KNOW HOW TO REWARD POINTS I WILL DO IT AS SOON AS I GET MY ANSWER.
    Thanks,

    Hi,
    To use a text variable on 0CALMONTH, 0CALMONTH need not be in Fomula as you mentioned.
    as you said,you have variable on 0CALMONTH and you wanted to see entered 0CALMONTH value in formulas.Right?
    From the context menu of formula>Edit->click on 'Select text variables'->a window will pop up which shows all existing text variables->(you can use any existing text variable of 0CALMANTH,ok..for time being we will go with new text variable)  go to starting point of the text variables window>double cilck on "New" node->provide Tech name and description for text variables and select 'processing by' as 'Replacement path'->next->select Characterstic ' 0CALMONTH'->next->select 'replace variable' with "KEY" or "TEXT">next>Finish.
    Use this Text variable in your formulas.
    Pl dont foget to assign points if it helps.
    Thanks

  • BRF -fetch formula  value  set in the expression

    Hi expert.
    My question is how to fetch formula  value  set in expression of BRF.
    Here is my scenario.
    For SC object BUS212 is have maintained the 2 levels approval process  as below .
    object type u2013 BUS2121
    Process schema - 3C_SC_700_002
    100-approval-u2018                 ' u2013 u2018        '  u2013 RR_EMPLOYEE- Specify Employee for Approval- 365-40007953- ' ' -dec entire doc.
    200-approval- AMT_LIMITu2013 limit ck u2013 RR_EMPLOYEE- Specify Employee for Approval- 250- 40007953- ' '-decision for entire doc.
    For second level approval system checks for SC cart  total amount  .
    In the BRF the expression type 0FB001u2019 (CL_FORMULA_BRF)  is  created  for event (AMT_LIMIT ) is EX_AMT_LIMIT_2
    here
    Expression  is of type u20180FB001u2019 (CL_FORMULA_BRF ), formula editor
    Has condition  0V_SC_TOTALVALUE ( Overall value) > 10000 (number)
    The process levels are maintained in  table u2018 /SAPSRM/C_WF_Lu2019  here I got the EVENT>  AMT_LIMIT.
    800         BUS2121              3C_SC_700_002                100         A             RR_EMPLOYEE  365                                  40007953
    800         BUS2121              3C_SC_700_002                200         A             RR_EMPLOYEE  304         AMT_LIMIT        40007954
    In table TBRF210  I got  event and Expression relation
    800         A             SRM_WF             AMT_LIMIT                        A             EX_AMT_LIMIT_2
    In table TBRF200 I got the BRF expression EX_AMT_LIMIT_2 and  object OV_SC_TOTALVALUE relation
    800         A             SRM_WF             F              EX_AMT_LIMIT_2                            F              A             0V_SC_TOTALVALUE
    Now here is my problem how to fetch condition  0V_SC_TOTALVALUE ( Overall value) > 10000 (number)
    Suggest the Class-method , tables or FM to fetch this 10000 value against    0V_SC_TOTALVALUE ( Overall value).
    Warm Regards.
    Indranil Panzade

    Hi ,
    first thanks for taking the interest in this thread .
    I need this  data matinated in BRF expression for my  custome (report and pplication)purpose.
    here  i maintained the value 10000 for SC total amount against some EXPRession .
    that i want to show in my report's  column like this
    Object- process levels-EVENT-EXPRESSION-valid amount(EXP.formula amt) -reposible person(AHUJA)plant-(1000).
    wants more explaination ,
    please reply.
    Indranil

  • Problem in formula:value getting round off

    Hi All,
    I  need to divide 2 keyfigures and fill it in one keyfigure..
    What i am doing , In transformation  i have 2 fields in datasource one is value and other is quantity and i  am mapping these 2 fields with one keyfigure in ODS..
    I am creating formula in rule in which I am dividing value by quantity (value/quantity) but when i am running DTP and loading data the value in my keyfigure is coming after rounding off... like
    I have value 4,311,781.58 and quantity 16,200.000 , if i divide i should get  266.159
    but in my ODS this value is coming as 266.16..
    Please advise how to remove this roundoff functionality...
    Regards
    Shweta

    Hi shweta,
    You have two options in this case.
    1. Go to your created key figure. After clicking on change go the tab 'Additional properties".
        There you can see Decimal Places under business explorer. you can change the number of places if you know to what    places you need the calculated value.
    2. Go to your created key figure. After clicking on change go to the first tab Type/unit and change your data type to FLTP- Floating point number.
    Hope it helps.
    Thanks,
    Rahul

  • Dimension formula values

    I have dimension members values  with formula. Though values are generated at member level,at the parent hierarchy level the values are not getting rolled up.
    I am in BPC7NW...any suggestion , inputs welcome...

    D,
    I  think there  is  some  miss communication  between  your question  and my  answer..either  i'm not able  to  understand  it  correctly
    pls  answer  these  questions.
    1)your  formulas  are  getting  calculated  and  right  amnts  are  posted  to  the base  level?
    2)how  are  you checking it.?
    3)refresh  your  client DIM files  under  options  in your  EVDRE  and  check  them  again..
    again...if  the  correct values  are   posted  to  your  base  members...the mdx  formulas  job is done...
    for  rolling  it up  to  the  parents  is your BPC  job (cube,  hierarchy,report)
    why  dont  you try  writing the  same  formula  on the  APPSHELL  Copy  and check  the  results...
    hope this  helps  D....
    I  cant  think  of  anything  else...

  • How to add a character before formula values in BEx.

    Hi Guys,
    Can anybody please let me know how to add a character before result of a formula.
    Ex. formula is 10/30*100
    I want to see in report 33.3 %
    thanks in advance
    peter b

    hi..
    You can use a formula variable with Customer Exit

  • Passing formula values to Crystal Reports from c#

    in an old vb 6 application we used to be able to call a function called PESetFomula in the Crystal Reports viewer and pass it the name of the parameter and the value.
    How do we do that now using Crystal Reports for VS 2013. I don't mean to set the criteria just to pass over parameters and values.
    Bill

    Hi Bill,
    Moving the thread to Crystal reports for Visual Studio Space.
    Using the .net SDK you could use the ReportDocument class to pass the parameter values to the report.
    See the sample applications here:
    http://scn.sap.com/docs/DOC-6929
    http://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports+for+.NET+SDK+Samples
    The developer guide and the API reference guide is here.
    http://scn.sap.com/docs/DOC-7824
    - Bhushan
    Senior Engineer
    SAP Active Global Support
    Follow us on Twitter
    Got Enhancement ideas? Try the SAP Idea Place
    Getting started and moving ahead with Crystal Reports .NET applications.

  • Diplaying some text when the formula value is negative

    Hi all,
    I am calculating the date difference using the formula  diff= date1- date2.
    My requirement is when the diff is negative it has to displayed as # or with some text but not as zero .
    Regards

    You can display some random number say 999999 instead of # or text.Is that feasible ?
    As # and text cannot be used for key figures.
    You can create a formula like :
    ( diff < 0 ) * 99999 + (diff >= 0 ) * diff
    Hope this helps.

  • Align Formula Values to Right Hand Side

    I am having a formula filed inside my crystal report that i want to align in the right direction when it get printed on my crystal report
    here is my formula
    IF ({ABC.NAME} = "John") THEN  {Notes.NOTE_details}
    else {ABC.old_ENTRY}
    Please advise
    thanking in advance

    Hi Muhammad,
    Is {Notes.NOTE_details} and {ABC.old_ENTRY} or images ? Or is it a long text ? what is the data type of these fields ?
    Can you try to right click on the field and go in Format field-- Common--Horizontal Alignment : select Right from the drop down and see..
    -Sastry

  • System status requirement in Threshold value formula

    Hi Pals,
    Kindly let me know how to use system status in the threshold values creation. just i will let u know what is my requirement
    System status = Created & (Planned date is less than 14 calender days).
    The problem is, i can't able to use this system status (Created) in threshold values formula

    Hi
    Check this out !!!
    Assuming that SYSTEM_STATUS field is availbale in the threshold Change Formula display.
    SYSTEM_STATUS = 'Created' AND SCHEDULED_START < 14
    Regards
    Senthil
    Award points if useful.

Maybe you are looking for