Formula by Group and based on a condition

Post Author: Ravi
CA Forum: Formula
Hi All,
I need to create a formula by Group and based on a condition. Below the syntax is wrong but this is the calculation that I am after!
Sum({@Test_Dollars}, ) where {Customer Number} = 12
Basically, I need to display/calculate the 2nd column in the sample report/output.
                  All Customers                    Only  Customer 12
Company    $500                                  $125    
    Zone A  $200                                   $50
   Zone B   $300                                   $75
Thanks in advance,
Ravi

Post Author: Jagan
CA Forum: Formula
I think you should be able to get this from a running total with a formula to only include records where the customer number - 12

Similar Messages

  • IDoc to file. Grouping and generation of files based on condition

    Hi All,
    I am working on a scenario, Idoc to File. I need to create number of files based on  occurrence of a field(vendor) in the idoc. Also the condition is to group by the field(vendor) and create as many files as the number of groups formed.
    For e.g.: In an Idoc if there are ten items present and 3 vendors who are supplying it. <b>The vendor and items can repeat in any order within the same idoc. </b>
    I need to group the items by the vendors and create a file separately for each vendor.  Like :   
    Item         Vendor
    Item1       V1
    Item2         V1
    Item3         V2
    Item4       V2
    Item5        V2
    Item6         V2
    Item1      V2
    Item2         V2
    Item3        V3
    Item6        V3
    What we have to achieve is, to group by the vendors irrespective of the order of the items or number of reoccurrence of the items.  As you see, the Item1 is supplied by both V1 and V2. I need to generate 3 files as follows:
    V1.xml with Item1 and Item2 details.
    V2.xml with Item3, Item4, Item5, Item6, Item1 Item2 details.
    V3.xml with Item3 and Item6 details.
    Can someone please help me with achieving this without using BPM?

    Hi Shashi,
    For this scenario you have to use multimaping without BPM using this blog.
    /people/jin.shin/blog/2006/02/07/multi-mapping-without-bpm--yes-it146s-possible
    And while doing your message mapping you have to use <b>removeContext</b> & <b>SplitByValue</b> (double clike the on splitbyvalue and select <b>value changed</b>) function. This function you have to use with the node in which your Vendor is coming. Example:
    if required to sort the vendor, then first sort the vendor in the below mapping.
    Vendor (NODE) -
    > removeContext -
    > SplitByValue (value Changed) -
    > IDOC.
    By doing this your vendor will be grouped and you will get new IDOC on change of  Vendor.
    Regards,
    Sarvesh

  • Unable to filter a formula field based on two conditions

    hi,
    I have a report with 3 subreports in it. When i drill down onto first subreport i am getting correct records in details based on selection criteria but when i am unable to populate the same record count in summary.
    For example
    On summary i see : 60 when i drill down i see 20 records which is correct but not reflecting onto summary report
    the details selection criteria is based on two  fields where field1>=1 and field2= "Text"It is coming out good (20 records) but in summary i am unable to populate this based on same selection criteria
    The main issue i am facing was if i apply a filter on summary selection criteria all the subreport counts are getting affected. Is there a way i can apply filters only one one field
    Please suggest
    Thanks!
    Lucky

    Thanks! for the prompt response Abhilash
    I got part of what you told me. Yes i am calculating the counts in the summary report.
    Basically here is the selection criteria: i need to filter the records based on two conditions. One is x.field1= "Admin" and x.field2=act_pct>=1
    For example:
    Admin Returns         50  but when i dig into details it showing as 20 records ( based on selection criteira above)
    when coming back to summary . 50 what ever is returing here is based on a formula ( if x.field1="admin" then 1 else 0) ..in addition to this i need to filter that by x.field2>=1 which is not taking it     
    Is there any syntax to do this
    If i apply a filter on this particular 50 record its bee applying for whole summary report ...
    And from what you said :
    Why don't you create the summary in the Subreport and maybe use shared variables to bring it back to the Main Report?
    i did not get this
    Please suggest
    Lucky

  • VT02N - do PGI and Invoice for certain deliveries either based on certain conditions

    Hi Friends ,
    We are using VT04 for creating shipments . While shipment completion stage in VT02N   an activity profile has been maintained  which does both the Goods issue and Invoice.
    We have a business requirement , PGI and Invoice should be created only for specific set of deliveries based on certain conditions.
    Is there any standard way to do this or by using user exits.
    Please guide.
    Thanks,
    Nileshsa.

    what about adding a check in userexit RV60AFZZ, when the condition is not met during invoice creation, error out and disable the creation of the invoice document?

  • Building a template - groups and formulas

    CR2008
    I'm trying to build a template to standardize some reports. I can get the header and the formatting fine: however, when I created a formula for Page M of N, the formula disappeared, and the field was replaced with one of the header fields. Does this just not ever work, or am I missing something?
    The documentation says "If an existing report is used as a template, these report objects will be applied to the new report: Fields, Groups, Summary fields". However, when I tried to save a grouping and apply it to an existing report, nothing happened - only the formatting came across.
    Thanks for any and all help!
    Edit: I added a TemplateField to my template and grouped on it, and applied it -- didn't work. However, when I then added grouping to the report, and re-applied the template, the new groups picked up the formatting from last time. When I added more groups than there were in the template, the newest groups were formatted the same as the last group I had specified. The Custom Group Name, which I had specified to be TemplateField2, (the same as the second grouping) still wasn't picked up, though. When I only specified a single TemplateField in the detail line, the Template Expert split the detail section into seven stacked detail sections, so that won't be much use.
    So, the other question remains: am I completely out of luck with formulas? And functions, for that matter? Thanks again!
    Edit again: I tried adding a Summary field to the template. While combining a text field and a summary field didn't work, dropping them next to each other did. Also, it only worked for the same summary: when I accidentally did a Sum instead of a DistinctCount, as the template was expecting, the formatting was ignored.
    Edited by: Garrett Fitzgerald on May 7, 2009 3:03 PM
    Edited by: Garrett Fitzgerald on May 7, 2009 3:34 PM

    Hello Rashmi,
    I'm not sure if I understood your question, but it seems you have to put your key figures in columns, together with time, if, for example, you want to show information like this:
    .........................................................                                                                           06.2008      07.2008 ...
    ..........................................................                                                 kf1 kf2....      kf1 kf2
    Org->Channel->customer->product  
    Please let me know if is this you are looking for.
    Best regards,
    Sue

  • Person DFF Context Value based on 2 criteria (Business Group and Emp Type)?

    Hello,
    We're implementing HR module into multiple business groups.
    I need to define context value for DFF "Additional Personal Details" based on 2 criteria Business Group ID and Employee Type
    Any idea how to do it?
    Thank you
    Elie

    Hello Elie,
    I am not sure on it,However have you tried creating a context with combination of Business Group and Person Type using merging,
    business_group_id || "_"|| person_type_id And structures would be something like 80_2112 Business Group id = 80 and Person Type id=2112.
    It may resolve your issue if this works out.
    Regards,
    Saurabh

  • Transportation Group and Shipping condition fields in Route determination

    Hello Guys,
    Please, I heard that if I leave Transportation Group and Shipping conditions field empty Route determination would consider whatever value I put in Material/Custumer Master.
    But the determination just happen if I put the exact value in either the determination and the Material Master for Transportation Group field for example.
    Have you ever determined Routes leaving the fields empty?
    Thank you,
    Regards,

    Hi,
    Those fields Transportation Group and Shipping conditions available in Route Determination are essential to trigger the correct route in Sales Order level.
    If blank the available routes need to be picked manually at Sales Order level.
    Kindly check .
    Regards,
    SRK

  • To make a field hide and show based on a condition.........

    hi all.
    i have a requirement where i need to make a set of regions alter based on which field we select....
    i have a LOV input and based on that the input the respective region has to be displayed..
    suppose i have 5 regions.....
    if i give 1 then the 1st region has to displyed.....similarly 2nd and 3rd......
    any help..........????????
    DEV

    Hi,
    Check the code snippet from Dev Guide:
    if (pageContext.isLovEvent())
    // Form was submitted because the user selected
    // a value from the LOV modal window,
    // or because the user tabbed out of the LOV input.
    // Find out which LOV input triggered the event.
    String lovInputSourceId = pageContext.getParameter(SOURCE_PARAM);
    // Find out the result values of the LOV.
    Hashtable lovResults =
    pageContext.getLovResultsFromSession(lovInputSourceId);
    if (lovResults != null)
    // Update the page depending on the value chosen by the user.
    It explains what you need.
    niranj

  • Suppressing a section based on two conditions

    Hello
    currently, I am trying to suppress a section of group based on two conditions:
    - The first condition is to suppress the section always if the user is not at DrillDownGroupLevel 1.
    - The second condition is to supress the section if the GroupName ({Customer.TerritoryID})  is not UK or US.
    I went to the section expert and entered this code in the "Suppress (No drill-down)" x-2 formula field:
    DrillDownGroupLevel <> 1 AND
    GroupName ({Customer.TerritoryID}) <> "US" OR
    GroupName ({Customer.TerritoryID}) <> "UK"
    Unfortunately, it does not work. Any ideas are very welcome!!
    I am using Crystal Reports XI
    Thanks in advance!!

    Which "section of a group" are you trying to conditionally suppress?  (group header, group footer or details within a particular group......or all of them?)
    AND you stated,
    "currently, I am trying to suppress a section of group based on two conditions:
    The first condition is to suppress the section always if the user is not at DrillDownGroupLevel 1.
    The second condition is to supress the section if the GroupName ({Customer.TerritoryID}) is not UK or US.
    Try this formula for the conditional suppression:
    (DrillDownGroupLevel  <> 1) AND
    (GroupName ({Customer.TerritoryID})  "US") OR
    (GroupName ({Customer.TerritoryID})  "UK")
    If that does not work you may want to check and make sure your values are upper case in the TerritoryID.
    In addition, a GOOD way to test conditional suppression formulas is to put them into a conditional highlighting color for the section so you can still see the values and the highlighting lets you know if it's working.  For example:
    IF
    (DrillDownGroupLevel  <> 1) AND
    (GroupName ({Customer.TerritoryID})  "US") OR
    (GroupName ({Customer.TerritoryID})  "UK")
    then YELLOW else WHITE

  • Use Parameter to choose Group and Sort options

    I've got a report that gets used for several different puposes, and needs to be grouped or sorted differently each time.  How can I use a parameter to let the user choose the group and sort options at runtime?
    I'm using CR2008, and SAP B1 2005.  The various grouping options I want to offer include SKU, Vendor and Description, and sorting within those Groups by SKU or Description.
    I'm a newbie with CR, so detailed instructions would be really helpful.

    You can create a report using parameter field. Follow these steps
    -- Create new parameter in the field explorer window
    -- The parameter shouls be static and enter all the field names on which you want to create in the values option
    -- Now create a formula like this
    if {?Parameter}="fieldname1" then
    else
    if {?Parameter}="fieldname2" then
    else
    -- Now insert new group and select this formula
    -- Now the group will change according to the parameter selected
    Please note that if you have different data types of fields you must need to convert totext()
    as If condition will allow only one data type output.
    Also when you insert any group by default the data is sorted on grouped field. If you want to sort on another field then you need to insert a summary field on that and go to report>group sort expert>select the field-->All based on the summary inserted.
    Hope this helps!
    Raghavendra

  • CR - giving total transaction count for few groups and 0 for few groups.

    For the column "No of First Call Resolution" I have to count no of interactions based on the Interaction Result, the formula is
    COUNT(Interaction_ID) WHERE INTERACTION_RESULT = 'FCR'
    For which, I wrote the below formula
    If {14CICustomerInteractions_query.Interaction Result} = "FCR" then Count ({14CICustomerInteractions_query.Interaction_ID})
    I have 33,232 interactions on the particular day I selected. When I try to group up and do the calculations it is giving total transaction count for few groups and 0 for few groups.
    Need Solution

    Hi,
    What field is the report grouped on?
    If you wish to find the no of interactions based on some condition and display it for every group, then here's what you need to do:
    1) Create this formula and place this on the details section:
    whileprintingrecords;
    numbervar c;
    If {14CICustomerInteractions_query.Interaction Result} = "FCR" then
    c := c + 1;
    2) Create another formula and place this one on the Group Footer:
    whileprintingrecords;
    numbervar c;
    3) Create this formula to reset the variable and place this on the Group Header:
    whileprintingrecords;
    numbervar c := 0;
    Let me know how this goes!
    -Abhilash

  • Displaying record based on the condition in Crystal report

    Hi All,
    I want to display certain records in crystal based on some condition.
    For example,
    If I am having 5 student records like,
    Name  Mark1 Mark2 Mark3 Total
    aaa      40       50       60      150
    abc      30       60       40       130
    tcr        25      25        25       75
    Now in table i have only 4 fields (STUNAME, MARK1, MARK2, MARK3).
    I have to calculate the total at runtime and if total is greater than 150, then actual record should display in report.
    For example, I can use formula to calculate total but I can calculate total only after each record prints. But i want to calculate total internally only it should display in report if condition satisfies. I dont want to keep one more field for total in crystal report.
    Please help me on this.

    If the filter is not "pushed" down to the database, then Crystal will pull all of the data into memory and then filter it there.  This is not a big deal if you only have a couple of records, but it can significantly slow down a report that is pulling in more than a few records.
    An alternative, if your report is just linking tables in the Database Expert, would be to create a SQL Expression that adds the three fields together.  Using this in the Select Expert WILL push the condition down to the database.
    If you're using a command instead of linking table, they you would add this to the Where clause of the comment.  If you're using a stored proc instead of tables or a command, you would want to do this filter in the code for the stored proc.
    -Dell
    Message was edited by: Dell Stinnett-Christy

  • How to create groups and assign users thru program

    Hi,
    I am planning to create groups by program and assign users to them based on some condition.Once users are assigned to those groups we need to change the Language value for those users in User profile
    We are using Central User Administration.
    Please let me know the solution
    Thanks
    Bala Duvvuri

    probably you can use this code to create a group
    IGroupFactory groupFact = UMFactory.getGroupFactory();  
    IGroup group = groupFact.newGroup(wdContext.currentContextElement().getGroup()); 
       group.commit();
    for this required com.sap.security.api.jar

  • Formula help - Group totals for more than one date range

    Post Author: melcaylor
    CA Forum: Formula
    I need to show in 3 columns
    inside of a grouping that totals an amount field based on a date
    range that amount was posted.  So for example:
    Billy Bob in the state of MA made $5.5m total, $800k in the last 21 days, $400k in the last 14 days and $150k in
    the last 7 days.
    I assume this is possible but I
    just donu2019t know what type of formula to write to make it work.  For this
    example, there are 2 tables u2013 user table and $$ table.  The User table has
    the user name, the $$ table has the pay date and the amount. 

    Post Author: SKodidine
    CA Forum: Formula
    You only need simple formulae in Running Totals to accomplish this.
    1.  Group by Name
    2.  Create the following Running Totals:
    2.1 A running total to sum the pay amount for all records, and resets on 'Change of Group' of Name.
    2.2 A running total to sum the pay amount and for 'Evaluate' click on the radio button next to 'Use a formula' and then click on X-2 button next to it.
    In the formula workshop window type a formula such as: {table.payment_date} in (currentdate - 21) to currentdate;
    For 'Reset' click on the radio button next to 'On change of group' and pick the group name.
    2.3 Create another running total just as in step 2.2 above but change the formula to: {table.payment_date} in (currentdate - 14) to currentdate;
    2.4 Create the last running total just as in step 2.2 above but change the formula to: {table.payment_date} in (currentdate - 7) to currentdate;
    Hide the details section and in the group footer place text boxes with appropriate text and insert these running totals to give you the numbers you want.
    The only issue I see with this is if a person was paid yesterday a sum of $25, then it will show $25 for total, last 7days, last 14days and also for last 21days.  At first look it might be mistaken for $75.

  • Advance Aggregation based on multiple conditions

    Hi members,
    I have a situation where I need to aggregate data based on multiple conditions. Relevant details of the problem is as follows.
    There is a table (let's call X). It has following columns:
    Transaction_Time (date)
    Transaction_direction (Possible values IN or OUT)
    Column_1
    Column_2
    Based on the columns: Transaction_direction, Column_1, Column_2, the type of the transaction will be derived. For example, if transaction_direction='IN' then transaction type is IN, if 'OUT' then transaction types are Out. Similarly if Column_1=Column_2 then transaction type is Txn_3 otherwise 4.
    Based on date and transaction types the aggregation will happen.The sample output would be:
    Time, Transaction type (IN, OUT, Txn_3, Txn_4), Sum of transactions
    10-June-2013 00:00  IN Transactions  2500
    10-June-2013 00:00  Txn_3 Transactions 3590
    and so.
    IN and Out transactions are easy to be derived using decode() function. However avoiding multiple UNION ALL and write a single SQL for all four conditions is tricky one.
    Hope I clarified.
    Neeraj

    What version of Oracle are you using?
    If you're on 11.x you can use the UNPIVOT feature as follows:
    with t (Transaction_Time, Transaction_direction, Column_1, Column_2) as (
    select date '2013-06-10', 'IN', 1, 1 from dual union all
    select date '2013-06-10', 'IN', 2, 2 from dual union all
    select date '2013-06-10', 'IN', 1, 2 from dual union all
    select date '2013-06-10', 'IN', 3, 4 from dual union all
    select date '2013-06-10', 'OUT', 3, 3 from dual union all
    select date '2013-06-10', 'OUT', 3, 4 from dual
    select * from (
    select
      transaction_time
    , sum(case when transaction_direction = 'IN' then 1 end)  as IN_count
    , sum(case when transaction_direction = 'OUT' then 1 end) as OUT_count
    , sum(case when Column_1 = Column_2 then 1 end)           as Txn_3_count
    , sum(case when Column_1 != Column_2 then 1 end)          as Txn_4_count
    from t
    group by transaction_time
    unpivot (
      txn_count for transaction_type in (
         IN_count as 'IN'
      ,  OUT_count as 'OUT'
      ,  Txn_3_count as 'Txn_3'
      ,  Txn_4_count as 'Txn_4'
    order by transaction_time, transaction_type
    TRANSACTION_TIME TRANSACTION_TYPE TXN_COUNT
    2013-06-10       IN               4      
    2013-06-10       OUT              2     
    2013-06-10       Txn_3            3      
    2013-06-10       Txn_4            3      
    If you're okay with getting one row per date with the 4 counts you can just use the inner select above, i.e.
    select
      transaction_time
    , sum(case when transaction_direction = 'IN' then 1 end)  as IN_count
    , sum(case when transaction_direction = 'OUT' then 1 end) as OUT_count
    , sum(case when Column_1 = Column_2 then 1 end)           as Txn_3_count
    , sum(case when Column_1 != Column_2 then 1 end)          as Txn_4_count
    from t
    group by transaction_time
    order by transaction_time
    TRANSACTION_TIME IN_COUNT OUT_COUNT  TXN_3_COUNT  TXN_4_COUNT
    2013-06-10       4        2          3            3      
    If you want to sum transaction amounts then use the same logic, except in the case statements replace 1 with the column you want to sum.
    Regards,
    Bob

Maybe you are looking for