How to declare a variable in Custom column formula?

I'm adding a new column and I have a formula like it:
if Text.Length(Text.Replace(Text.Replace([Text], "-", ""), " ", "") ) = 4
then "CB0" & Text.Range(Text.Replace(Text.Replace([Text], "-", ""), " ", "") , 2)
else Text.Replace(Text.Replace([Text], "-", ""), " ", "")
i want to do something like it:
string = Text.Replace(Text.Replace([Text], "-", ""), " ", "") ) 
if Text.Length(string) = 4
then "CB0" & Text.Range(string, 2)
else string

The issue you have is that you haven't output 'string' anywhere.  You can create a column with the manipulated text and then reference that column when applying the if statement.
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
String = Table.AddColumn(Source, "ReplacedText", each Text.Replace(Text.Replace([Text], "-", ""), " ", "")),
AddColumn = Table.AddColumn(String, "EndResult", each if Text.Length([ReplacedText]) = 4
then "CB0" & Text.Range([ReplacedText], 2)
else [ReplacedText])
in
    AddColumn

Similar Messages

  • How to declare a variable in form

    how to declare a variable in form?

    Hi,
       do you want to create variable in script or smartform?
    In scripts to define a variable use the following declaration statement.
    DEFINE &<VARIABLE_NAME>&
    place this statement as command. we can assign initial value for this by adding VALUE ' ' to above statement.
    If your requirement is for smartforms go to global declaration, create a variable there that will be applicable only for smartform.
    Hope this will help you,
    Regards,
    Aswini.

  • How to declare class variable with generic parameters?

    I've got a class that declares a type parameter T. I know how to declare a static method, but this doesn't work for a static variable:
    public class Test< T >
        * Map of String to instances of T.
        * error: '(' expected (pointing to =)
        * <identifier> expected (pointing to () )
       private final static < T > Map< String, T > MAP = new HashMap< String, T >();
        * Get instance of type T associated with the given key.
       public final static < T > T getType( String key )
          return MAP.get( key );
    }Edited by: 845859 on Mar 20, 2011 11:46 AM

    jveritas wrote:
    I'm trying to create a generic polymorphic Factory class that contains boilerplate code.
    I don't want to have to rewrite the registration code every time I have a different return type and parameter.I haven't seen a case yet where that is reasonable.
    If you have hundreds of factories then something is wrong with your code, design and architecture.
    If you have a factory which requires large number of a varying input types (producing different types) then something is probably wrong with your code and design.
    A reasonable factory usage is one where you have say 20 classes to be created and you need to add a new class every 3 months. Along with additional functionality represented by the class itself and perhaps variances in usage. Thus adding about 3 lines of code to one class is trivial. Conversely if you have hundreds of classes to be created by the factory and you are adding them daily then it is likely that
    1. Something is wrong with the architecture which requires a new class every day.
    2. You should be using a dynamic mechanism for creation rather than static because you can't roll out a static update that often.
    More than that the idiom that leads to factory creation is different for each factory. A factory that creates a database connection is substantially different than the one used in dynamic rules logic processing. A generic version will not be suitable for both.
    Actualy the only case I know of where such a factory might be seem to be a 'good' idea is where someone has gotten it into their head that every class should be represented by an interface and every class created by a factory (its own factory.) And of course that is flawed.

  • How to display presentation variable in a column

    Hi all....I have to display presentation variable in a column...
    I tried placing @{variable_name} in column formula..
    But it is displaying a value 0 ..where the variable carries a date value.
    Any suggestions?

    Take a look at this blog: http://gerardnico.com/wiki/dat/obiee/presentation_variable
    Try it out by providing a default format.
    Thanks,
    BIPuser

  • How to declare local variables in PL/SQL stored programs

    Where do I declare local variables in a PL/SQL stored program?
    I get compiler errors with either of the options below:
    FUNCTION GET_PRINCIPAL_BALANCE (CUT_OFF_DATE IN DATE, TITLE_SN IN DATE, TOTAL_BALANCE OUT NUMBER) RETURN NUMBER IS
    TOTAL_BALANCE NUMBER;
    BEGIN
    RETURN TOTAL_BALANCE;
    END;
    FUNCTION GET_PRINCIPAL_BALANCE (CUT_OFF_DATE IN DATE, TITLE_SN IN DATE, TOTAL_BALANCE OUT NUMBER) RETURN NUMBER IS
    BEGIN
    TOTAL_BALANCE NUMBER;
    RETURN TOTAL_BALANCE;
    END;

    Your local variable cannot have the same name as the formal out parameter. This is a procedure example, but since functions should not have out parameters anyway ...
    session2> CREATE PROCEDURE p (p_id IN NUMBER, p_did OUT NUMBER) AS
      2     p_did NUMBER;
      3  BEGIN
      4     p_did := p_id * 2;
      5  END;
      6  /
    Warning: Procedure created with compilation errors.
    session2> show error
    Errors for PROCEDURE P:
    LINE/COL ERROR
    0/0      PL/SQL: Compilation unit analysis terminated
    1/1      PLS-00410: duplicate fields in RECORD,TABLE or argument list are
             not permittedThe proper way to create a function would be something like:
    CREATE FUNCTION f (p_id IN NUMBER) RETURN NUMBER AS
       l_did NUMBER;
    BEGIN
      l_did := p_id * 2;
      RETURN l_did;
    END;You should really assign a value to the variable before you return it.
    John

  • How to make the display of custom column names in UWL(not bother abt values

    Hi all
    i want to make the display of custom column names in UWL ( for example GP)
    i dont want or not looking about values for those custom columns . i know that thru custom connector we can achieve to retrieve the values for those custom columns. but currently i am looking only just to display the custom column names( for example GP custom column names, just i want to display the name of the columns ) in UWL .
    Thanks
    Sunil

    Hello Prashant,
    You can add the control to your custom pagelayout, the following article has an example:
    http://spandps.com/2012/02/22/showing-the-audience-target-field-in-an-editmodepanel-sharepoint-sp2010-in-projectserver-ps2010/
    Btw, the SPFieldTargetToControl has a required property:
    http://msdn.microsoft.com/en-us/library/microsoft.office.server.webcontrols.fieldtypes.spfieldtargettocontrol.required(v=office.14).aspx
    - Dennis | Netherlands | Blog |
    Twitter

  • SSIS Programming- How to declare a variable of type Object?

    Hello, I have a very specific coding question. I am trying to create a pkg using SSIS Object model. I am trying to create a variable of type Object. But I could not find any reference in KB or forums on creating variable of this data type.
    Example:
    // Create the package.
    Application a = new Application();
    Package p = new Package();
    p.Name = "MyDataExtractPkg";
    //Add Variables to the pkg
    Variables pkgVars = p.Variables;
    Variable var8 = p.Variables.Add("varHour", false, "User", (System.Int16)0);
    Variable var9 = p.Variables.Add("varHourDiff", false, "User", 0);
    Variable var10 = p.Variables.Add("varIntervalWaitInMS", false, "User", 5000);
    Variable var11 = p.Variables.Add("varJobCnt", false, "User", 0);
    Variable var12 = p.Variables.Add("varjobID", false, "User", 0);
    Variable var13 = p.Variables.Add("varJobRS", false, "User", (System.Object)0);
    Variable var14 = p.Variables.Add("varProcessDate", false, "User", "abc");
    As you can see I was able to successfully variables of Type Int16, Int32(default) & String.
    But I need to create a variable of type Object for "varJobRS" and above code is generating int. Appreciate any direction or help on how to create Object variable type.
    Thanks,
    DW Guy

    I have been continuing with my work with intention to approch MS, but I came across the solution in one of the Blog site. The solution is :
    var13.Value =
    new
    Object();
    This converts the variable of type Object.
    The link that gave this soluion is:
    http://ssisbi.com/building-ssis-packages-programmatically-part-5/
    Thanks,
    DW Guy

  • How to change the variable value in fox formula?

    Hi All,
        Please help me achieve this scenario,
             in the variable selection screen , i wil give some i/p like, calyear(0calyear) = 2008.
          In planing function using FOX formula, i must be able change the variable value to 2009.
      Will it be possible to achieve this, can we change a variable value using FOX formula, if possible
    please let me knw how to achieve this.
    Thanks n Regards,
    Priya.

    Hi Priyadarshini,
    i dont know what is your requirement exactly.If you can give a better explanation of ur requirement we can help you. But to answer your question yes we can get new values for the variable in the planning function.
    for this you need to couple the planning function together with the planning filter in a planning sequence. This planning filter should have the variable that you wanted to change. In the WAD when you want to call this planning sequence there is an option to call variable screen. If you enable this, it will pop up the variable screen to get this value again.
    Guess this was helpful.
    Regards.
    Shafi.

  • Date variable in a column formula

    Hi
    I am having trouble using date-values from a Dashboard Prompt in a column formula in Answers.
    The situation:
    I use a dashboard prompt to select a date, the selected date stored in a presentation variable ('production_end'). In an answers request, I would like to use the 'selected_date' value to filter values for one column:
    FILTER("Measures new".Produced USING(Calender."Full Date" = @{production_end}{timestamp'2009-07-31 00:00:00'))
    Error after prompt execution:
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <00>: Syntax error [nQSError: 26012] . (HY000)
    SQL Issued: {call NQSGetQueryColumnInfo('SELECT FILTER("Measures new".Produced USING(Calender."Full Date" = 2010-07-14 00:00:00 FROM source_db')}
    SQL Issued: SELECT FILTER("Measures new".Produced USING(Calender."Full Date" = 2010-07-14 00:00:00 FROM source_db
    There is no problem using the production_end in a column filter to filter the whole request, the error only shows up whenever I try to use it in a column formula.
    Hope you can help.
    Thanks
    Regards
    Andy

    Hi Kart,
    I think I found the problem and the solution.
    I use a dashboard prompt with a default value based on a repository variable ('today'). The prompt feeds a presentation variable ('prod_end').
    In the answers request I use prod_end in the following column formula (I changed the request slightly compared to the ones we were discussing - the basic functionality of using the presentation variable is the same):
    MONTH(timestamp'@{prod_end}')
    That combination leads to the follow error when opening the dashboard for the first time:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000]
    [nQSError: 10058] A general error has occurred.
    [nQSError: 46047] Datetime value TIMESTAMP '2010-07-15 00:00:00' from TIMESTAMP '2010-07-15 00:00:00' does not match the specified format. (HY000)
    The first timestamp probably being the timestamp defined in my column formula, the second one (the one selecting from) probably being the repository variable definition.
    Solution:
    If I default the dashboard prompt using an sql statement to refer to the repository variable 'today' it works
    Default prompt to:
    SELECT Calender."Full Date" FROM OLS where Calender."Full Date" = VALUEOF("today")
    Thanks for your help
    Regards
    Andy

  • How create table with variable number of columns?

    I am creating table data in Java. Number of columns is variable. How I can write <table> in UIX.
    Here is code of one of my unsuccessful attempt:
    <provider>
    <!- get table data like DataObjectList-->
    <data name="ReportTableData">
    <method class="app.ReportTableData" method="getTableData"/>
    </data>
    <!- get names of columns like DataObjectList-->
    <data name="ColumnNames">
    <method class="app.ReportTableData" method="getColumnNames"/>
    </data>
    </provider>
    <table data:tableData="@ReportTableData">
    <contents data:childData="@ColumnNames">
    <text data:text="nameColumn"/>
    </contents>
    </table>
    I hoped that I can get cell data by key, where key is name of column. But cells of table contain only names of columns.
    Please help me, where I mistaken?
    Thank you.

    Hi Sergey,
    The UIX table implementation relies on a childData like mechanism internally to iterate over the rows. For instance, when you databind the text attribute of the UINode used to stamp out each column, you are relying on the uix:table iterating over the table data using the data object for the current row when evaluating your column stamp.
    Setting the data:childData attribute on the table's contents element conflicts with UIX's internal iteration over the tableData. For this reason, we don't support specifying a dynamic number of table columns in UIX XML.
    This doesn't mean that you can't do it, there are different strategies. If you've got a finite and known set of columns, you can specify each possible column and then databind the rendered attribute of each one to hide and show it as appropriate. Another, often cleaner approach, is to build this subtree of UINodes in Java code.

  • How to declare bind variable in package

    hi,
    i have created one package with insert and returning the value in procedure using bind variable.
    -- spec part.
    SET SERVEROUTPUT ON
    VARIABLE id NUMBER
    CREATE OR REPLACE PACKAGE pack_sale AS
    PROCEDURE pro_insert_SOHeader (
    SO_HEADER_ID NUMBER,
    SO_NO VARCHAR2,
    SO_TYPE VARCHAR2,
    SO_APPROVED_FLAG VARCHAR2,
    SO_DATE DATE,
    CUST_HEADER_ID NUMBER);
    END pack_sale;
    -- body part
    CREATE OR REPLACE PACKAGE BODY pack_sale AS
    PROCEDURE pro_insert_SOHeader (
    SO_HEADER_ID NUMBER,
    SO_NO VARCHAR2,
    SO_TYPE VARCHAR2,
    SO_APPROVED_FLAG VARCHAR2,
    SO_DATE DATE,
    CUST_HEADER_ID NUMBER) IS
    BEGIN
    INSERT INTO SO_Header VALUES (SEQ_SOHEADER.NEXTVAL,SO_NO,SO_TYPE,SO_APPROVED_FLAG,SO_DATE,CUST_HEADER_ID)
    RETURNING SEQ_SOHEADER.CURRVAL INTO :id;
    COMMIT;
    END pro_insert_SOHeader;
    END pack_sale;
    I have run this package in sql*plus,it will return the warning message like
    PLS-00049: bad bind variable 'ID'.
    i do not know how to rectify this error
    and how to execute this procedure in sql*plus.
    please help me...

    hi,
    when i was running the body script the error is displayed in
    sql*plus like
    SQL> @"D:\Viji Share\ex_body"
    SP2-0042: unknown command "" - rest of line ignored.
    15 /
    Warning: Package Body created with compilation errors.
    SQL> show error
    Errors for PACKAGE BODY PACK_SALE:
    LINE/COL ERROR
    11/30 PLS-00049: bad bind variable 'ID'

  • How to declare global variables using another global variable in ODI

    I am declaring a gloabal variable using another global variable.
    say for example:
    I have a global variable empid.
    I am decalaring another global variable empname in refreshing tab of global variables and the select statment is
    select empname from emp where empno = #GLOBAL.empid -------if i write like this i am getting error as invalid character.
    select empname from emp where empno = '#GLOBAL.empid'-------if i write like this i am getting error as invalid number.
    I have kept the datatype as numeric and action as non persistent
    Please help
    Thank you in advance.

    Hi,
    You cant test/refresh empname standalone.
    You need to create a new package drag and drop both variables and make them as refresh variable and execute that package and test.
    Flow,
    empid----> empname
    Thanks,
    Guru

  • How to declare a variable available for across all applications??

    Dear Friends,
    If i declare a global variable in the component controller it will be available during its runtime and its value get expired if i open same webdynpro component application in different log-in.I need to access one variable across all login of users and across many webdynpro applications created.What should i do??
    Please advice me.Thanks in advance.

    Thanks  Mr.Gardiner for your reply,
    I do not know much about this Shared Memory Objects can you please help me.
    My requirement is that my application which is attached to the portal has access to many concurrent users. I have a screen for which there is a edit button,  on click of which i need to restrict other users from edit . This is based on portal ID and another unique id for that screen.I thought of lock object but  i guess that wouldnt help me b'se i am not writing anything to the database but need to restrict users in controlling the editability of the UI element.In this scenario user can be same user with different application or another user using this application.
    So if i save those unique ID's acrros applications,  i can validate and throw a message for other users when they try to do edit action when one user is already doing it.

  • How to create Presentation variable for columns and to use it in Narrative?

    Hi All,
    Anybody know how to create presentation variable for a column (i.e., i need to create it in edit formula section itself). And then, I should use it in Narrative section to display that column value. Is it possible? Or do i need to use any other variable for this requirement? If so please let me know, how to create it? This is very urgent requirement.
    Thanks in Advance
    Thenmozhi

    Hi Satya,
    I just want to create a table that should horizontally display the values like below:
         SUID Tag # :123456               Year Mfg: 2007                                                                                     
         Description: computer corporation FA ID#: 4576
         Model Number: 4569 hESC: #ert
         Serial Number: 78945 Flags: c
    Department: Hematology
    User: thenmozhi
    Database: OLAP
    I think we can create this type of report using either Narrative or Static Text. But I am not sure whether it is possible or not? And also another thing is that sectioning is applied for SUID Tag # column. So, depending on the dashboard prompt if the SUID Tag # retrieves two or more values.
    Then the first value for example 123456     and the values for the other columns related to this SUID Tag # value should display in the first page (i.e., page 1). And if the next value of the SUID Tag # for example say 678901 then the values should move to second page that is like this:
         SUID Tag # :678901               Year Mfg: 2008                                                                                     
         Description: Computer Manufacturing FA ID#: 4577
         Model Number: 4570 hESC: #eth
         Serial Number: 78946 Flags: G
    Department: Hematology
    User: Rehman
    Database: OLAP
    Thanks
    Thenmozhi

  • How to have SharePoint search custom columns in a custom list?

    Hello,
    How can have SharePoint search custom columns in a custom list?  I have a custom list for a directory with names, department, title and phone numbers.  Department and titles are not searchable with the search box for the list.
    How can I make these 2 custom columns searchable?
    Thanks
    Paul

    Any text added to any property is searchable. If you have a Sales department search for "sales", but I think you are asking about doing a property search like "department=sales" or "department:sales".
    2013 has a different way than 2007 and 2010 to create Managed Properties. You will need to create a Site Column and then a little configuration. The basic steps are:
    Create a Site Column (as SP already has a Department column you will want to create one with a difference name such as CorpDept.)
    Add the column to a list or library and add data. (won't be found otherwise)
    Wait for the next content crawl. (or manually start a crawl)
    Go to the tier where you want to define the managed property and go to the Schema page:
    Central Admin, Search Service, Schema
    your site, Settings (gear), Site Settings, Search Schema (in the Site Collection Admin section)
    your site, Settings (gear), Site Settings, Schema (in the Search section)
    Click Managed Properties and search for your column name. It might look like this: ows_q_TEXT_CorpDept.
    Edit the Managed Property and give it a useful Alias, such as "CorpDept".
    Test the search:    CorpDept:Sales
    Do a web search for "SharePoint 2013 Site Column Managed Properties" for examples.
    Mike Smith TechTrainingNotes.blogspot.com
    Books:
    SharePoint 2007 2010 Customization for the Site Owner,
    SharePoint 2010 Security for the Site Owner

Maybe you are looking for

  • How can I return to a previous WINDOW using keyboard

    When I was using Explorer, I simply could use ALT+TAB to go from the window I was viewing to the last window I had viewed before that. When I use ALT+TAB withe Firefox 3.6, most of the time it goes to another window other than the last one I had view

  • Media doesn't load in "open" dialogue, tries to connect to wrong location?

    keep getting this dialogue: " There was a problem connecting to the server ( my dads old computer) " what's going on?

  • Can't connect 2TB Time Capsule to my home network

    I can't seem to get my new 2TB Time Capsule to show up in Airport Utility on my MacBook Pro. I started out trying to connect wirelessly, then with an Ethernet cable directly between the Time Capsule and my MacBook. Still, the new device does not appe

  • Open Directory Server "not responding"

    This is strange, and I'm not sure what if anything is wrong... My server is an OD Master. LDAP, Password Server, and Kerberos all report running. AFP authentication is set to Kerberos (only). Authenticated directory binding is enabled. Client compute

  • PROBLEM SAVING A PROJECT

    Adobe Premier CS6: I can't save the project to another hard drive for safety. I've tried with large projects and then with small ones as that didn't work. I start with the Project Manager, "collect files and copy project to a new location" and I rend