Is it possible to use a variable semantically as an invisible "column"?

Here is a simple query that produces a table:
let
    Source = #table(     type table [First= number, Second= number],      {{1,1}, {2,4}, {3,4}}     ),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each [First]+[Second])
in
    #"Added Custom"
I would like to replace the formula used in #"Added Custom" with a variable which abstracts the calculation and the fields used.  Something like this (which does not work):
let
    Source = #table(     type table [First= number, Second= number],      {{1,1}, {2,4}, {3,4}}     ),
    Sum = [First]+[Second],
    #"Added Custom" = Table.AddColumn(Sum, "Custom", each Sum)
in
    #"Added Custom"
Is this possible?

You can do this using a custom function. (Note: "each" is just shorthand for "(_) =>", i.e. a function with one argument named "_".)
let
    Source = #table(type table [First= number, Second= number], {{1,1}, {2,4}, {3,4}}),
    Sum = each [First]+[Second],
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Sum(_)),
in
    #"Added Custom"
You could also eliminate the "each" from Added Custom if you like:
#"Added Custom" = Table.AddColumn(Source, "Custom", Sum)
Ehren

Similar Messages

  • Is it possible to use repository variable in conditional formatting

    Is it possible to use repository variable in conditional formatting . if no then is there any workaround for implementing the same....
    Also i came across a sql of an init block.. which goes like 'exec OracleBi..procedure_name'
    Is 'OracleBi..' a keyword or something like that....

    Refer http://www.biblogs.com/2008/09/03/obiee-repository-variables-filtering-and-conditional-formatting/
    Init blk is calling any procedure here with name OracleBI here...no any specific significance.
    Hope this help
    Edited by: Deepak Gupta on Aug 12, 2011 8:27 AM

  • Possible to use local variables in Calculation Manager

    Hi,
    I'm using calculation manager in EPMA for the first time. Have not found any function for using "local variables", i.e. variables that can be used for fixing on the current members a user has selected in a form. Do someone know if it is possible to use that functionality in calculation manager? And in that case, how do I find it?
    Thanks!
    Regards
    Mats

    Hi,
    I guess you are referring to local variables in Essbase Administration Console. When you are in calculation manager (System View), you can go to Tools->Variables. There you can create variables at application, database (global) or business rule level (local variable). You can use these in Business rules by placing the name in curly bracket {...}.
    The usage of the variables in the forms is the same as before.
    If however, what you meant to say by local variables is substitution variables, yes you can use them in Calc manager the same way you use in calc script.
    Cheers,
    Alp

  • Is it possible to use a variable after

    ...after popup message. Like the following example. I want to inform the user about the next number he can enter into a database..
    MESSAGE 'Please enter another value. The value may be  '  +  VARIABLENAME TYPE 'I'.
    How can I achieve using a variable after this message or any alternative way?
    Thank all you very much.
    Deniz.

    hi,
    u can do it.
    To create a message long text in SE91:
    Select  to switch to change mode.
    Place the cursor on the corresponding message.
    Click the Long text pushbutton.
    This starts the SAPscript editor.
    Enter the long text.
    Carry out a check in SAPscript editor.
    Save your data.
    eg: create a msg like this.
    Please enter another value. The value may be &.
    then in pgm do this.
    MESSAGE i014(msg_class_name)  WITH variable_value.
    Rgds
    Reshma

  • Is it possible to use a variable value

    with pop up message. Like that:
    message 'Already recorded. Please type another number. The next possile number is ' PossibleNUmberVariableName type (I).
    is such a thing possible?
    Please help. I neen it.
    Thanks.
    deniz.

    yes for every message there will be 4 message variables.
    PossibleNUmberVariableName type (I).
    message i888(sabapdocu) with 'Already recorded. Please type another number. The next possile number is ' PossibleNUmberVariableName.
    where sabapdocu is a message class that was all ready availble, may be u need to use another one after creating. That message will contain 4 message variables &1 &2 &3 &4' like this.

  • Is it possible to use a variable in the name of other variables?

    Trying to avoid a long post; is there some command in Java that would allow a variable to be read before the rest of the statement it is in?
    For example, using a pair "@" to encapsulate a variable with the mystery command I'm looking for:
    *public class Example {*
    *public static void main (String[] args) {*
    Char variable = "A";
    int @variable@_Status = 0;
    So that this application would create an integer named "A_Status" and assign it a value of 0. Obviously, I'm not looking to be told that "int A_Status = 0" is the best way to do that, I'd like "variable" to be able to be defined by input or change somehow in the code. I have a gut feeling that this is impossible due to the compiler, but I'd like a more professional opinion. Anyone?

    The variable "name" is a lot less important than you think. In fact, when your code is compiled, the computer doesn't care one jot about the name of the variable.
    You should not worry about trying to do this, but rather should tell us the reason why you would even want this. If we knew that, we could show you a better way, guaranteed.

  • Is it possible to use a variable to control the path where a sub-flow is found ?

    I have a customer on UCCX 7.0.2 SR5.
    They are developing a script that uses many sub-flows and they wish to have a "Development" , "QA" and a "Production" versions of the application all on the same box.
    I can build the applications easily enough but the challenge I'm running into is we want to also have 3 different sub-directories in the repository to hold the different versions of the scripts and the sub-flows.  The thought is the developers can keep working on modifying the code while the QA team tests the latest build without affecting each other.  Then there is a separate production version of the script that has previously passed QA and is public facing.
    Example: the directory structure where the scripts are stored.
    \root of repository
         App-Dev
         App-QA
         App-Production
    In a script, it seems that you have to browse to the location in the repository and directly select the subflow you want.
    This is a challenge since when I copy my code from the development to the quality assurance directory I have to go thru and edit all the references to the sub-flow to the QA directory.
    Ideally I'd like to do the following:
    Define a string variable "Script-Path" and assign it to the desired directory
    then call the subflow
    SCRIPT[Script-Path\ScriptName.aef]
    this doens't seem to work.
    Has anyone found a solution to this challenge ?
    Thanks

    Hi,
    Does the subflow script and the script that calls it are in the same folder??
    If the script was originally loaded from disk, the subflow script must reside in the
    same folder as the script that calls it. If the script was loaded from the Repository,
    then the subflow must also reside in the Repository.
    EDIT: My first comment was because I though you were trying to call a script directly from disk.
    Now for scripts that are in the repository I did some tests. I have the root directory where I placed the main script and then I have another directory called Test where I placed the subflow script.
    My main script is:
    Start
    Accept
    PlayPrompt (audio.wav)
    Subflow(subflowVariable)
    End
    *subflowVariable is a parameter with value "Test\subflowScript.aef"
    My subflow script plays a prompt.
    So when I test this everything worked just fine
    Gabriel

  • Where its not possible to use a variable (&&var) in SQL*PLUS ?

    SQL*Plus Command Reference - DEFINE
    Whenever you run a stored query or script, SQL*Plus substitutes the value of variable for each substitution variable referencing variable (in the form &variable or &&variable)
    The question is which are the limits of this. Can eg even be between a 'STR&&varING' passed as parameter to some function? Or as parameter I can pass only a single variable and there isnt such auto-casting level ?
    I have created DBCA Scripts to batch create a DB. So I want inside these scripts to replace the DBNAME with a variable. So I can create different DBS with these prescriptions from an API tool.
    E.g here there are 6 different scenarios where I might need to pass the variable. I dont know
    1. On which of the bellow scenarios I can inject the &&var
    2. On which I cant and thus have to create a 2nd VAR to inject the 1st one
    3. Which dont accept variables at all - but only static text
    @D:\app\admin\DBNAMEY\scripts\CreateDB.sql
    spool D:\app\admin\DBNAMEY\scripts\CreateDB.log append
    startup nomount pfile="D:\app\admin\DBNAMEY\scripts\init.ora";
    CREATE DATABASE "DBNAMEY"
    DATAFILE 'D:\app\oradata\DBNAMEY\system01.dbf' SIZE ...
    GROUP 2 ('D:\app\oradata\DBNAMEY\redo02.log') SIZE 51200K,
    I may not start testing the scripts 6 times fearing corrupting my Workstation on half executed scripts.

    GoodfireGeorge wrote:
    SQL*Plus Command Reference - DEFINE
    Whenever you run a stored query or script, SQL*Plus substitutes the value of variable for each substitution variable referencing variable (in the form &variable or &&variable)
    The question is which are the limits of this. Can eg even be between a 'STR&&varING' passed as parameter to some function? Or as parameter I can pass only a single variable and there isnt such auto-casting level ?
    I have created DBCA Scripts to batch create a DB. So I want inside these scripts to replace the DBNAME with a variable. So I can create different DBS with these prescriptions from an API tool.
    E.g here there are 6 different scenarios where I might need to pass the variable. I dont know
    1. On which of the bellow scenarios I can inject the &&var
    2. On which I cant and thus have to create a 2nd VAR to inject the 1st one
    3. Which dont accept variables at all - but only static text
    @D:\app\admin\DBNAMEY\scripts\CreateDB.sql
    spool D:\app\admin\DBNAMEY\scripts\CreateDB.log append
    startup nomount pfile="D:\app\admin\DBNAMEY\scripts\init.ora";
    CREATE DATABASE "DBNAMEY"
    DATAFILE 'D:\app\oradata\DBNAMEY\system01.dbf' SIZE ...
    GROUP 2 ('D:\app\oradata\DBNAMEY\redo02.log') SIZE 51200K,
    I may not start testing the scripts 6 times fearing corrupting my Workstation on half executed scripts.
    If you can't test because you are afraid the test might fail, you need to address that issue first.  No one on the web is going to give you iron-clad assurance that some code you write is going to work exactly as you expect.
    Your script is trying to create a database?  What's the worst thing that can happen if it doesn't work?  Do you know how to manually dis-mantle whatever your script does?  If not, you need to learn.  The knowledge you will gain from that exercise will go a long way to improving your understanding of how these things interrelate.

  • Can I use bind variable instaed of writing static COLUMN Name

    Hi , I am having a table containing id and column names, the data is stored against that id in other tables. Now I wish to update data into another table so that it goes into apppropriate column without using decode function.
    I am trying to do this:
    EXECUTE IMMEDIATE 'update TEST set :1 = :2
    where PROJECT_ID= :3 and UNIQUE_ID= :4' using P_DEST_COLUMN, P_TEXT_VALUE, P_PROJ_ID, P_TASK_UID;
    the values P_DEST_COLUMN, P_TEXT_VALUE, P_PROJ_ID, P_TASK_UID are populated using a cursor in PL/SQl
    Is this statement valid? If not can you tell me how to do it as I am getting some error I am unable to comprehend.
    thanks
    Rishabh

    Column names cannot be substituted at run-time as bind variables. If you need to specify the column name at run-time, you'd need to construct a new string and execute that string dynamically, i.e.
    EXECUTE IMMEDIATE 'UPDATE test SET ' || p_dest_column || ' = :1 ' || ...From a data model standpoint, storing column names as data elements in another table is generally a rather poor idea. It's likely to make ad-hoc reporting nearly impossible and to cause a lot more parsing than would otherwise be required.
    Justin

  • Can we use repository variables in SQL statement of column prompt?

    Hi Dudes,
    Below is the query
    SELECT "- End Date"."End Fiscal Year" FROM "Consumer Sector" WHERE ("- End Date"."End Fiscal Year" = valueof (current_year)) or ("- End Date"."End Fiscal Year" = valueof (current_year) -1)
    when use this sql in criteria prompt getting error.
    Please suggest .
    thanks.sri

    Make sure your syntax is correct it should be like VALUEOF("CURRENT_YEAR")-1
    If you still have issues then VALUEOF("CURRENT_YEAR")-1 cast it to int before you subtract.
    If helps pls mark as correct else let share error message

  • Using a variable in a view?

    I know that it may not be possible to use a variable within a view, but I'm wondering if there isn't a work-around? If there is a single value---pulled from another table---you wish to reuse in a view that does not use dynamic SQL, how do you do so? I've been toying around with WITH statements, but that's getting me nowhere. I'm using 11r2.
    BTW, please do not ask me the standard litany of angry-dba questions (why are you doing this? your database is f*****, RTFM, etc.), this is just for my own curiosity. :)
    Thank you
    Example for demo purposes only (I know it's not syntactically correct):
    variable var_value varchar2(30)
    begin
    select this_is_just_one_value
    int :var_value
    from tableX where column1 = 'BOB';
    end;
    select
    numerous_columns
    from tableY
    where
    column5 = :var_value;

    893968 wrote:
    BTW, please do not ask me the standard litany of angry-dba questions (why are you doing this? your database is f*****, RTFM, etc.), this is just for my own curiosity. :)Why are you doing this? your database is f*****! RTFM! Etc!! ;-)
    SQL is not a procedural language - so you cannot create a view for example that has a parameter signature. E.g. this is possible in a procedural language:
    declare
            cursor c( deptID number ) is
                    select * from emp where deptno = deptID;
    begin
            open c( 1234 ); --// open SQL cursor using a parameter/variable
            --// etc..
            close c;
    end;This is not possible using a SQL object like a view. As a view is not a procedure. So the same approach as the above using SQL (silly example, but do demonstrates the basics):
    // define
    create or replace view emp_view as select * from emp;
    // use
    select * from emp_view where deptno = 1234;The CBO is clever - and it will likely push such a predicate into the emp_view SQL statement.
    To parameterise such a view, is ugly. And should only be considered when dealing with issues such as security and data restrictions. A context is created - this can contain a number of name-values. The view can then use a name-value from the context. Oracle's data dictionary views use this approach.

  • Using a variable in Struts config, to redirect

    In the struts-config file,
    to redirect to a different site, I can use
    redirect="true"
    and mention full path, in my <forward path=
    variable.
    1. Is there a better way to do it?
    2. Since I have to do it in multiple places, is it possible to use a variable? I mean, something like this
    <forward
    name="success"
    path="URL/abc.html" />
    Where URL is a variable name that the site path? This way, I can reuse the variable to redirect to other pages too (xyz.html, for example)

    Hi there,
    I don't know...is there only one URL you are using ore are there more than one? Because if it's the same path everytime you can try using this:
    <forward
    name="success"
    path="./abc.html" />
        ./               // This is the shortcut for the directory you are currently using.
        ../              // This is the shortcut for the directory above the one you are currently using.This code should do it. If not, try to create a var named for example "vpath" and put it like this:
    <forward
    name="success"
    path=vpath+"abc.html" />Try and tell if it worked ;)
    X--spYro--X

  • How to use one variable as a default value for another variable?

    Hi Experts,
    Is it possible to use one variable as a default value for another variable?
    For example:
    Variable 1 = current calendar year month
    Variable 2 = mandatory input ready variable for calendar year month
    I want to use variable 1 as default value for variable 2, but also have the ability to change the month if required.
    Thanks!
    Kathryn

    u can use replacement path variable
    in that case u can replace the values of 1 variable with the another variable...
    but  u cannot do this setting
    u cannot make variable 2 as mandatory
    u cannot enter value for variable 2
    because by default it will take the value of variable 1
    u have to make follow settings
    variable 2
    name , technical name
    processing by = replacement path
    infoobject = ocalmonth
    next tab
    replaced by another variable
    variable name
    offset start , offset lenght
    save and hit okey

  • Using Bind Variable in a SELECT

    Hi,
    I'm trying to build up my SQL query at run-time using bind variables and in the Oracle® Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1) it says that 'After defining the bind variables, the next step is to reference them in the SQL statement. While SQL syntax allows bind variables to appear both in the SELECT list and in the WHERE clause, you'll typically use them in the latter context, as part of your WHERE clause.'.
    However, when I try to use the bind variables in my SELECT list because I've had to set a type for the variable to String the variable gets inserted with inverted commas either side e.g. SELECT 'Service' FROM TestTable. Is it possible to use bind variables to insert a value into my select list without these inverted commas around it?
    Thanks in advance,
    Tom

    OK, thanks for your response. Do you know of a way then where I can control my SELECT parameters programmatically? I'm currently trying to do it using the information in the chapter '35.9 Using Programmatic View Objects for Alternative Data Sources' from the Oracle® Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1). I think I'm part way there, would this be the correct way of acheiving what I want?
    Cheers, Tom

  • How to use a variable in a cursor?

    Hi,
    Is it possible to use a variable as condition for fetching data using cursors? The code works fine ( as shown) without using the clause 'where empno < 7600'. How can I use the variable 'stmt' in defining/fetching data by using cursor cur_1? My target is to get info for employee whose empno<7600. Any inputs would be appreciated.
    DECLARE
         STMT VARCHAR2(50) := 'EMPNO < 7600';
         CURSOR CUR_1 IS SELECT EMPNO, ENAME, JOB, MGR FROM EMP;
    BEGIN
         OPEN CUR_1;
         LOOP
              FETCH CUR_1 INTO :EMP.EMPNO, :EMP.ENAME, :EMP.JOB, :EMP.MGR;
              EXIT WHEN CUR_1%NOTFOUND;
              NEXT_RECORD;
         END LOOP;
         CLOSE CUR_1;
    END;

    Hi:
    You could use a CURSOR Parameter:
    DECLARE
    CURSOR CUR_1 (empno_in IN VARCHAR2) IS SELECT EMPNO, ENAME, JOB, MGR FROM EMP WHERE empno < empno_in;
    BEGIN
    OPEN CUR_1 (7600);
    LOOP
    FETCH CUR_1 INTO :EMP.EMPNO, :EMP.ENAME, :EMP.JOB, :EMP.MGR;
    EXIT WHEN CUR_1%NOTFOUND;
    END LOOP;
    CLOSE CUR_1;
    END;
    or a REF Cursor, like so:
    DECLARE
    TYPE CUR_1_TYPE IS REF CURSOR;
    CUR_1 CUR_1_TYPE;
    BEGIN
    OPEN CUR_1 FOR SELECT EMPNO, ENAME, JOB, MGR FROM EMP WHERE empno < 7600;
    LOOP
    FETCH CUR_1 INTO :EMP.EMPNO, :EMP.ENAME, :EMP.JOB, :EMP.MGR;
    EXIT WHEN CUR_1%NOTFOUND;
    END LOOP;
    CLOSE CUR_1;
    END;
    Note - these will run in SQL*Plus ... I believe you are using Oracle Forms as you had the NEXT_RECORD command in your example, and I had to remove it.

Maybe you are looking for