Using a formula to populate an array

Post Author: GPMichal
CA Forum: Formula
I need some help creating an array for use in a {table.field} In ["value1", "value2", "value3"......] formula (we'll refer to it as {@supression}) which will be used as conditional supression for groups  .  I would like to populate the above array box with unique values in a record set.  I want a formula (we'll refer to it as {@array}) to look at all the records in the record set and return each unique value and put them in the array box between the " ".  The field values will be unique, duplicates and/or null.  I will group and sort the record set by the field value intended to fill the array box so that all the null values will show up after the unique or duplicate values.  For example, the record set might look like this:
Code      Type
Code1       A
Code2       A
Code3       B
Code4       C
Code5       C
Code6       Null
Code7       etc............
Using the above record set, {@array} would populate the array box of {@supression} so it would look like this: {table.field} In ["A", "B", "C"].  I realize that I will probably have to have {@array} return just "A", "B", "C" first so I could insert it into {@supression} so it would look like this:
{table.field} In [{@array}]
I assume the only way to accomplish this is to use some type of loop formula like "Do...While", "While...Do", "For....Next", etc. but I'm not sure.  If there's an easier way please tell me.  Otherwise, can someone give me an example of a loop formula that would do the trick?
Thanks,
Gary

Post Author: GPMichal
CA Forum: Formula
Thanks for your input.  I will admit that I'm learning as much as I can about CR and I do have much more to learn.
I'll try to explain the issue without going into a lot of detail if I can.  It may not be possible without the detail though.
Basically, I have a main report and two closely related subreports.  The main report groups budget item records by type.  A subreport located in the same group lists related cost records only if the cost CATEGORY matches the budget TYPE.  The 2nd subreport groups cost records by CATEGORY and only needs to show them if the CATEGORY is NOT already listed along with a matching budget TYPE above.  In order to do this, I had to develop a way for the report to scan the budget TYPES already listed in the detail of the main report and arrange them horizontally in field for use in a conditional flter formula.  Originally I was referring to this horizontal value as an array but that was probably the wrong assocation to use.  I finally figured out how to do this on my own and this is what I did:
I created a manual running total based on the budget type string field but did so in such a way that it would not include duplicates:
If OnFirstRecord Then
Shared StringVar BudgetType:= ' " ' + table.budgettype + ' " '
Else If Previous(table.budgettype)=table.budgettype Then
"duplicate"
Else
BudgetType:=BudgetType + ' " ' + table.budgetype + ' " ';
Which produced a result like something like this: "AL""GR".......etc.
I then used Shared StringVar BudgetType in the Group Name  conditional filter for the 2nd subreport like this:
NOT(table.costcategory IN SharedStringVar BudgetType)
So using the above results, if a cost category was equal to either "AL" or "GR" the group wouldn't be listed in the 2nd subreport.
Clear as mud???

Similar Messages

  • How to read XI Data type in Java code and populate as array list, using UDF

    Hi,
    How to read XI Data type in Java code and populate as array list, using UDF?
    Is there any API using which  the XI data types can be read?
    Kindly reply.
    Richa

    Input Structure:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:CustomerCreateResp xmlns:ns0="urn:bp:xi:up:re:cust_mdm:cmdm:pr5:100">
       <CUSTOMER>
          <item>
             <CUSTOMERNO/>
             <MDMCUSTOMER/>
             <CREATE_DATE/>
             <RETURN>
                <TYPE/>
                <MESSAGE/>
             </RETURN>
             <PT_CONTPART_RETURN>
                <item>
                   <MDM_CONTACT/>
                   <CONTACT/>
                </item>
             </PT_CONTPART_RETURN>
             <PARTNERS>
                <item>
                   <CUSTOMERNO/>
                   <PARTNER_FUNCTION/>
                   <PARTNER_NUMBER/>
                   <DEFAULT_PARTNER/>
                </item>
             </PARTNERS>
          </item>
       </CUSTOMER>
    </ns0:CustomerCreateResp>
    Output structure
    (Sample output structure.This actually needs to be mapped and generated using UDF)
    <?xml version="1.0" encoding="UTF-8"?>
    <ns1:updateCustomer xmlns:ns1="urn:xiSericeVi"><ns1:customer><ns2:ArrayList xmlns:ns2="java:sap/standard">[]</ns2:ArrayList></ns1:customer><ns1:name>2344566</ns1:name></ns1:updateCustomer>

  • Formula automatically populate the date when inventory goes to "zero"

    Hello- I am trying to create a formula that will automatically populate the date when inventory goes to "zero".
    Date: Row 3 Columns P-AB
    Inventory: Rows 5-400 Columns P-AB
    Column J rows 5-400 is where I want the inventory run-out date to auto-pop
    with so many rows of data, where stock goes to "O" will clearly vary per row. I want this formula, to look between Col. P-AB and tell me in Col. J when my inventory goes to "zero"
    Thank you!

    Thank you for your reply...using your formula, I'm still not coming up with inventory run-off date from row 3.
    I need Column J to give me the date when my inventory is "0".

  • Using mathscript formula to create test sound question tia sal22

    Greetings All
    I'm trying to use mathscript formula to create an audio file and I'm not sure why my vi is not working.  It says the data type has to be string but the graph just shows a blank line
    TIA
    sal22
    Attachments:
    mathscript formula to sound test.vi ‏274 KB

    Building a waveform from a formula requires special syntax.  The mathscript node is trying to output a 1-D array.  Rather than trying to fold your formula into something the waveform generator can understand, I recommend just building the waveform directly.
    I tested it, and did not get the straight line.  Dunno if the sound is working properly, as I do not have a soundcard.
    Message Edited by jasonhill on 06-16-2006 11:45 AM
    Attachments:
    mathscript to waveform.PNG ‏13 KB

  • How to populate dynamic arrays?

    Hi all.
    i am bit new to java
    i need to capture data from a text file and populate an array
    my text file looks like this ,
    Jemma 14
    Arnold ferrer 45
    Dave P 10
    Gule Whatson Clerk 50
    any idea ?

    Hi,
    I am giving sample code, then you run.
    I am not getting whether populate in the Array or ArrayList. Now i am giving using ArrayList.
    Using StringTokennizer is the Best solution for your reauirement.
    List list = new ArrayList();
    File file = new File(" employee.txt");
    FileReader freader = new FileReader(file);
    BufferReader breader = new BufferReader(freader);
    String inLine = null;
    st = new StringTokenizer(inLine, DELIM);
    while ((inLine = inputStream.readLine()) != null) {
    list.add(st.nextToken());
    Best Regards
    Maruthi

  • How to get field data using a formula

    I have a table with fields ‘pension contribution’ and ‘current year’.The first field stores a single record for a given year.Say if ‘current year’ is 2014 ‘pension contribution’ is 7% and so on.
    I wanted to get a result by providing a certain year from another field in a table using a formula.
    How do I do this?An explanation would be helpful.

    Hi Nebil,
    You can't! You'll need to join the the two tables or use a Subreport.
    -Abhilash

  • Can I use a formula node to start the execution of a case structure?

    Hi,
    I am working on editing a VI to make it much easier to understand (for colleagues and non LV users). For one reason or another, the VI's creators did not fully make use of the power of case structures and other structure types. In the application we need it for, the instrument cycles and repeats measurements on several objects. We are interested in measuring the motor currents for several motors in the system. As it stands now, for each sample object's run, there is a separate sub-vi diagram which displays its waveform trace and several indicators such as max current, time at max, etc. That code was contained within a T/F case structure and copied and pasted 20 plus times.... Obviously the vi became extrememly cluttered and needed a huge screen to see. The trigger for the current case structures is an EQUALS comparison between one input (which is the sample object counter; and this part I will likely leave unchanged since it makes a lot of sense already) and a constant which was defined 1 through 20+ for case. 
    I have since made one case structure and 20+ instances of that case and have labeled them (at the top selection box near the detent arrows) "1", "2", 3, etc. I am wondering if I can use a formula node to act as the "trigger" which sets each case structure running? I believe that a simple IF statement should work. Please see a snippet of my attempt at making this in C below.
    For the node, I defined X as the input and Y as the output. The input to the node, X, is connected to the sample object counter. The output, Y, is connected to the case selector of the case structure. My attempt at the code is below:
    int32 y
    For(x == 1)
       y = "1";
     For(x == 2)
       y = "2";
    etc, etc.
    Is that above code snippet correct? Do i need something like "ENDIF" or "end if" at the end? Does "y" have to be defined as "int32" or can it be something else?
    Thanks for the help!

    Is your formula node doing anything else besides what is shown?
    Why don't you just wire the value that is going into it at X directly into the selector of the case structure?
    Attachments:
    Example_VI_BD.png ‏2 KB

  • I need to get 2 decimal places when using a formula for a quotient and Numbers will only give me whole integers which is useless since most items will be less than 1. How can I change this?

    How do I get 2 decimal places when using a formula for a quotient? It only gives me whole integers. Most of the results will be less than 1 so I need 2 decimal places

    the quotient function returns only whole number portion of the dividing two numbers.  If you want the actual decimal value use the divide operator.  you enter this as:
    A/B
    if the numerator is in A1 and the denominator is in B1 you can enter the formula like this:
    =A1/B1

  • How to use a Formula Column in the main query?

    Hi All,
    I've tried to use a formula columns defined in some query in the condition of that query like this:
    where (:cf_ex - :cf_ex2) >= 5
    but when I run the report no data returned! Why? and how to use it the condition of the query?
    Note: I'm using Forms 6i

    where (:cf_ex - :cf_ex2) >= 5You cannot do that. Formula columns are not part of the select statement (which runs in the database), but are processed in the report.
    When you created this query, my guess is that you got the message "Note: the query Q1 has created the bind parameter(s) cf_ex, cf_ex2". Check these User Parameters in your data model. So, you are actually referencing user parameters in the query, not formula columns.
    I made a computations and things using PL/SQL that can't be done in the select statement in the data model!If it's pl/sql you can probably use that in your query. Create some database functions for cf_ex and cf_ex2 and use these in your query.

  • Can you use a formula field as the default value of a parameter?

    I'm wondering if you can use a formula field as the default value of a parameter. I have an date parameter that is being pulled from a stored procedure. When I run the report, it defaults to the current date and time. I would like it to default to he current date and have the time be 00:00:00

    Hi,
    Unfortunately, you cannot use a formula field as the default value of the parameter.
    And, to get rid of the current time and show 00:00:00, all you need to do is Edit the parameter and set the 'Default Value' to 00:00:00. This will take care of the time portion, however the date portion would be set to the year 1899 and not the current date.
    Hope this helps!
    -Abhilash

  • "Using a CIN to Create an Array of Strings in LabVIEW" example crashes LV on Linux

    Tried to utilize this NI example: "Using a CIN to Create an Array of Strings in LabVIEW" (http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B4B282BE7EF907C8E034080020E74861&p_node=&p_source=External)
    Compiles OK with the makefile made by the LV's lvmkmf utility. Nevertheless when I try to run the VI (with the code loaded into the CIN, of course), LabVIEW 7.1.1 on a SUSE 9.3 Linux machine crashes:
    LabVIEW caught fatal signal
    7.1.1 - Received SIGSEGV
    Reason: address not mapped to object
    Attempt to reference address: 0x0
    Segmentation fault
    Any ideas? Did anybody try this on a Windows machine?

    H View Labs wrote:
    Tried to utilize this NI example: "Using a CIN to Create an Array of Strings in LabVIEW" (http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B4B282BE7EF907C8E034080020E74861&p_node=&p_source=External)
    Compiles OK with the makefile made by the LV's lvmkmf utility. Nevertheless when I try to run the VI (with the code loaded into the CIN, of course), LabVIEW 7.1.1 on a SUSE 9.3 Linux machine crashes:
    LabVIEW caught fatal signal
    7.1.1 - Received SIGSEGV
    Reason: address not mapped to object
    Attempt to reference address: 0x0
    Segmentation fault
    Any ideas? Did anybody try this on a Windows machine?
    This code is badly broken. In addition to resizing the actual handle to hold the number of string handles you also would need to create the string handles itself before attempting to write into them. NumericArrayResize is the fucntion to use as it will either resize an existing handle (if any) or create a new one if the value is uninitialized (NULL).
    /* resize strarr to hold handles to NUMSTRINGS strings */
    err = SetCINArraySize((UHandle)strarr, 0, NUMSTRINGS);
    if (err)
    goto out;
    /* perform this loop once for each element */
    /* of array of strings being created */
    for (i = 0; i < NUMSTRINGS;) {
    LStrHandle handle = (*strarr)->arg1[i];
    /* determine length of string that will be element of strarr */
    strsize = StrLen(str[i]);
    err = NumericArrayResize(uB, 1, &handle, strsize);
    if (err)
    goto out;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    /* moves strsize bytes from the address pointed to */
    /* by str[i] to the address pointed to by the data pointer in the handle */
    MoveBlock(str[i], LStrBuf(*handle), strsize);
    /* manually set size of string pointed to by *strarr */
    (*((*strarr)->arg1[i]))->cnt = strsize;
    /* manually set dimSize of strarr */
    (*strarr)->dimSize = ++i;
    return noErr;
    out:
    return err;
    Rolf KalbermatterMessage Edited by rolfk on 06-30-2005 03:15 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How can I convert from Modbus raw data to engineering units using a formula?

    Within Lookout, I have several Modbus numerical input types that do not have a linear corespondence to the Engineering values they represent.  How can I display these values accurately using a formula to convert from the raw data to an engineering value?

    I don't quite understand your reply.  I'm using Lookout 6.0.2, logged in as Administrator, in Edit Mode.  The Modbus object is named RTU06_SAV.  The Active member is 30002 with an alias of SAVfmSMT_RSL.
    Following your instructions, I opened Object Explorer and right-clicked on RTU06_SAV. 
    This opened a menu containing:  Refresh, Cut, Copy, Rename, Delete, Edit connections..., Edit Data Member Configuration, Configure Network Security and Properties.
    I assumed that I should select Edit Data Member Configuration, but maybe I'm wrong. 
    Within Data Member Configuration I can set up Linear Scaling between Raw data and Engineering data.  I know how to do that, but what I need to know is how to convert Raw data to Engineering data using a formula representing a non-linear transformation (such as a converion to a logarithmic value or perhaps a formula derived by fitting the formula to a curve on a calibration chart).
    Once I have this my Engineering data can be represented on a control panel as both a numeric value AND as a correctly reading Gauge.  It can also be properly represented on a HyperTrend graph.
    What do you suggest?

  • How to populate an array with random text files.

    I am making a Jeopardy program. I have my program set up so that it retrieves 5 random text files. I just want to know how I populate one array with all the lines from the text files my program is retrieving.

    You can read a textfile line by line and add each line to an ArrayList. An ArrayList is very much like an array only that it's "open ended". You can start adding lines without first knowing how many you're going to get. If you still want an ordinary "static" array when you're finished reading lines you can easily get one from the ArrayList and then drop the ArrayList.

  • SSRS Use a formula for a line graph y = mX + b

    Hi I want to show a line on a line chart using a formula in the form y = mX + b.   Can't seem to get this to work.   I inputted the formula into the "Value field" of the "Data field" but the line doesn't show up.
    X = value for X axis (it's a date);  m and b are query fields (both type real)    The data is grouped on two fields that are specified in the "series field"
    There are multiple values for X but only one value for M and B.
    So for all dates (X) for each Group 1 AND Group 2 combo: chart this line.
    Using: SSRS Visual Studio 2008

    Hi 317704,
    Linear Regression line might be what you need, you have to get the records in the database using the T-SQL for all the points on the X-Axis following the below formula. Where n is the total number of data points, and the tis and yis are the components of
    the data point tuples (ti, yi).
     I give a sample below,
    My datasource(AdventureWorksDW2008):
    DECLARE @start_month
    SMALLDATETIME
    DECLARE @end_month
    SMALLDATETIME
    SET @start_month
    = '2002-01-01'
    SET @end_month
    = '2002-12-01';
    SELECT
    CAST(CONVERT(CHAR(6),DimTime.FullDateAlternateKey,112)
    + '01'
    AS
    SMALLDATETIME)
    AS CalendarMonth
    ,SUM(SalesAmount)
    AS y
    FROM FactInternetSales
    INNER
    JOIN DimSalesTerritory
    ON FactInternetSales.SalesTerritoryKey
    = DimSalesTerritory.SalesTerritoryKey
    INNER
    JOIN DimTime
    ON FactInternetSales.OrderDateKey
    = DimTime.TimeKey
    WHERE DimSalesTerritory.SalesTerritoryKey
    = 9 --Australia
    AND
    DATEPART(YEAR,DimTime.FullDateAlternateKey)
    BETWEEN
    DATEPART(YEAR,@start_month)
    AND DATEPART(YEAR,@end_month)
    AND
    DATEPART(MONTH,DimTime.FullDateAlternateKey)
    BETWEEN
    DATEPART(MONTH,@start_month)
    AND DATEPART(MONTH,@end_month)
    GROUP
    BY CONVERT(CHAR(6),DimTime.FullDateAlternateKey,112)
    You could get some reference from top sample.
    Thanks,
    Challen Fu
    Challen Fu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Using Dimension Formulas to sum data based on different criteria

    Hi all,
    I am trying to use a u201CDimension Formulau201D to perform the following calculation:
    We have an account dimension which has 2 important properties:
    1.     CRITERIUMTYPE: This property can have 3 different values: u201CWERKu201D, u201CINVu201D OR u201CLIQu201D
    2.     ACCTYPE: This property can have 2 different values: u201CEXPu201D or u201CINCu201D
    The client wants to have a report that sums data based on these 2 properties. An example will help to clarify this:
    ACCOUNTS     CRITERIUMTYPE     ACCTYPE     VALUE
    ACCOUNT A         WERK                          EXP               100 u20AC
    ACCOUNT B         WERK                          INC               150 u20AC
    ACCOUNT C         WERK                          EXP               200 u20AC
    ACCOUNT D         WERK                          INC               300 u20AC
    ACCOUNT E         INV                          EXP               50 u20AC
    ACCOUNT F         INV                          INC               100 u20AC
    ACCOUNT G         INV                          EXP               200 u20AC
    ACCOUNT H         INV                          INC               500 u20AC
    The clients wishes to see this data in the following way:
    CRITERIUMTYPE     ACCTYPE     VALUE
       WERK                         EXP              300 u20AC
                                        INC              450 u20AC
       INV                         EXP              250 u20AC
                                     INC              600 u20AC
    In order to achieve this I have created several new accounts, one for each combination e.g.: Account WERKEXP is used to sum the data on the combination CRITERIUMTYPE=WERK and ACCTYPE=EXP. I have created a dimension formula in my account dimension but this is where I am stuck. I have created the following formula to calculate the account WERKEXP:
    IIF([BUDGETPOSITIE].CURRENTMEMBER.PROPERTIES("ACCTYPE")="EXP",IIF([BUDGETPOSITIE].CURRENTMEMBER.PROPERTIES("CRITERIUMTYPE")="WERK",[BUDGETPOSITIE].CURRENTMEMBER,0),0)
    The problem with this formula is the following:
    The formula will add all amounts that meet the 2 criteria mentioned in the formula, EXP and WERK, but as soon as it finds an accounts that does not match the 2 criteria it will set the account WERKEXP back to 0. I need to know if there is a way, using dimension formulas, of adding these values together without the new account being set to 0 as soon as one of the accounts it needs to check does not meet 1 of the 2 criteria.
    We are working on SAP BPC 7.5 for NW with SP04
    All help is very much appreciated!
    Kind regards,
    Stefano

    Hi,
    You can also use ParentHn property to have different grouping of accounts within the dimension.
    So in your case rather using the member formula you can have four accounts and add them in the Parenthn property for grouping it.
    1. The Solution proposed by Nilanjan is specific for a Report/IS and Performance will be good
    2. My solution will be global something similar to MDX formula, but performance may be slightly lesser than using excel function.
    Hope this helps,
    Regards,
    G.Vijaya Kumar

Maybe you are looking for

  • N8 music player not recognising music file details

    I've been using mp3tag to embed album art in the ID3 tags & also fix the album artist so I can copy the files across to my N8 in windows. It all worked fine before but now the music player just sees them as album artist & album unknown, depite this i

  • HT4623 How can I facetime with out WIFI on a iphone 4 ????

    HELP ??? I see that you can facetime with out WIFI, But i can not on my phone  ... I have the IPHONE 4 ......HELP

  • Buzzing on playback

    I've just upgraded to Garageband 11 through the app store. Playback through my Edirol FA-66 is badly distorted. On garageband startup, playing a song, or previewing a loop just produces buzzes If I use the Garageband prefs to select the FA-66 as an o

  • Workflow for INBOUND IDOC

    Hi, I want to set you a workflow for one IBOUND idoc coming via edi partner. I want to use the organization units and then assign the user to it. what are the steps required for setting up a new workflow totally from the start for a IDOC / Message ty

  • X-Fi Xtreme Audio and no sound

    This is really getting annoying. I had a X-Fi Fatality FPS before (which had no optical on the back), and then i bought a X-Fi Xtreme Audio.. but.. The mic just doesnt want to work. I connect the mic jack to the only input there is - where the mic ic