Max date by month in expression builder

Hello
I'd need to create a new logical column and use the expression builder to make this column return only the last day of each month. I know at answers level I can write something like this in the formulas: Max(Date by month). However I can't do that in expression builder as it doesn't like the word 'by'..
Is there a way to get it done?
Thanks in advance!

Hello,
The max(date) should work in logical layer. As when you pull in month it automatically groups by month.
thanks,
deep

Similar Messages

  • Compare only DATE portion of a datetime field in Expression builder

    Hi! All,
    This may be a simple question, but I couldn't find the answer. I have a query where I want to say :
    Expression exp = exp1.get("startDateTime").equal(pDate);
    here pDate is a java.util.Date class with a time stamp.
    I wish to basically compare just the DATE portion of the value stored in the data base with only the DATE portion of "pDate" and ignore the time component.
    How do I do this in expression builder?
    By the way we are on Toplink 9.0.4.5
    Thanks

    There are a couple of ways to accomplish this. You could use between(beginningOfDay,endOfDay) where beginning of day is 12:00:00am on the date specified in pDate and end of day is 11:59:59pm on pDate. Or you could consider using a combination of dateName(), datePart(), and/or truncateDate() expressions to compare at the day, month, year level. I am not sure which would give you better performance, so you might need to do some testing to verify.
    In the first case, create beginningOfDay and endOfDay based upon the date housed in pDate. Then:
    Expression selectionCriteria = exp1.get("startDateTime").between(beginningOfDay,endOfDay);
    In the second case, there would be a little more code to write:
    Expression startDateTimeExp = exp1.get("startDateTime");
    Expression dayExp = startDateTimeExp.datePart("day");
    Expression monthExp = startDateTimeExp.datePart("month");
    Expression yearExp = startDateTimeExp.datePart("year");
    int desiredDay = get day of month from pDate;
    int desiredMonth = get month of year from pDate;
    int desiredYear = get year from pDate;
    Expression selectionCriteria = dayExp.equal(desiredDay).and(monthExp.equal(desiredMonth)).and(yearExp.equal(desiredYear));
    Check out the TopLink API docs on the Expression class for more details on what these Expression building methods do : http://download-west.oracle.com/docs/cd/B10464_05/web.904/b10491/index.html
    Hope that helps,
    Doug

  • How to use TRUNC function with dates in Expression Builder in OBIEE.

    Hi There,
    How to use TRUNC function with dates in Expression Builder in OBIEE.
    TRUNC (SYSDATE, 'MM') returns '07/01/2010' where sysdate is '07/15/2010' in SQL. I need to use the same thing in expression builder in BMM layer logical column.
    Thanks in advance

    use this instead:
    TIMESTAMPADD(SQL_TSI_DAY, ( DAYOFMONTH(CURRENT_DATE) * -1) + 1, CURRENT_DATE)

  • Query to select value for max date from a varchar field containing year and month

    I'm having trouble selecting a value from a table that contain a varchar column in YYYY-MM format. 
    ex.
    Emp_id Date Cost
    10264 2013-01 5.00
    33644 2013-12 84.00
    10264 2013-02 12.00
    33644 2012-01 680.0
    59842 2014-05 57.00
    In the sample data above, I would like to be able to select the for each Emp_id by the max date. Ex. For Emp_id 10264, the cost should be 12.00.

    create table test (Emp_id int, Date varchar(10), Cost decimal (6,2))
    insert into test values(
    10264, '2013-01', 5.00 ),
    (33644, '2013-12', 84.00 ),
    (10264, '2013-02', 12.00 ),
    (33644, '2012-01', 680.0 ),
    (59842, '2014-05', 57.00 )
    Select Emp_id,[Date],Cost FROM (
    select *,row_number() Over(Partition by Emp_id Order by Cast([Date]+'-1' as Datetime) Desc) rn
    from test)
    t
    WHERE rn=1
    drop table test

  • SSAS Max date in grouped set of records

    I have a query where I need to pull back the latest risk assessment rating for a record, but need to do this for all records from the query. I have MS
    SSRS Report Builder (V3) as the only way to access this data and no access to modify the underlying cubes which are provided by a supplier.
    My basic MDX which pulls out the data needed is the following:
    SELECT
    NON EMPTY {
    [Measures].[No of Investigations]
    } ON COLUMNS,
    NON EMPTY { (
    [Investigation Indicators and Text Fields].[Investigation Reference Number].[Investigation Reference Number].ALLMEMBERS *
    [Risk Assessment Rating].[Risk Rating].[Risk Rating].ALLMEMBERS *
    [Risk Assessment Completed Date].[Date].[Date].ALLMEMBERS *
    [Risk Assessment Completed Time].[Time HHMM].[Time HHMM].ALLMEMBERS
    ) } ON ROWS
    FROM [Investigation]
    which leaves my Date and Time needing to be concatenated. I have carried this out as a calculated field but am unable to then test for a max value as it gives me an error around using an aggregate function.
    Is anyone able to provide me with any ideas on how to carry this out, either via the MDX statement
    or subsequently. Ideally I would like to be able to create the results in two ways - one with all records and a marker showing which is the latest assessment, and one which just pulls back the subset via MDX.
    For clarity the source system holds Investigation records as the core item of interest, and these can have multiple risk assessments attached to them (of different types). I need to return the latest risk assessment against each investigation. If at all possible
    it would be good to return all investigations, with or without risk assessments, as the missing records need to be quality assured. 
    Thanks for any help, ideas or pointers on this. 

    Hi Steven,
    According to your description, you want to marker the Max date in the assemessments, right?
    Generally, when creating a date dimension in a SSAS project, the dimension members were sorted in date order. So the last date is the max date. We can get the last date using ClosingPeriod function. Here is a sample function for you reference.
    with member [measures].[a]
    as
    ClosingPeriod ([Date].[Calendar].[Date],[Date].[Calendar].currentmember).name
    select {[measures].[a]} on 0,
    [Date].[Calendar].[Month].members on 1
    from
    [Adventure Works]
    Reference
    http://msdn.microsoft.com/en-us/library/ms145584.aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • Expression Builder: convert string to number

    Hi all,
    I'm having trouble building a field validation rule for bank account numbers.
    The numbers have 12 positions, so I cannot use a string or text number.
    The validation rule to be implemented is that the last two digits are calculated based on the first 10 (modulo 97).
    However, when I use the Mid function to pick the first characters, I am unable to do any calculations on it. Apparently, the string to number conversion doesn't work (it should work when I read the manual, as it says that when using an operator between two data types, the second type is converted to the first (cf. example of 1234+abcd (should result in 1234 as to the manual))). So I tried '1*Mid(...)' or '0+Mid(...)'. Syntactically the expression builder accepts it and I can save it. BUT when I change the particular value on the screen, it gives me an SSO error (not the Field Validation error message I entered).
    Why isn't there simply a function ToNumber (like ToChar)????? How could I workaround this?
    Any input very welcome!
    Frederik

    Apparently, I was a bit confused when typing the first sentence, it should be:
    The numbers have 12 positions, so I cannot use an integer or number data type, but have to use String.

  • Logical SQL about Expression Builder

    Dear all
    I am Michel.
    When I was always trouble,
    everyone will go to support this Forum, I am glad.
    I want to fix Logical SQL about Expression Builder of Oracle BI 11.1.1.3.
    In detail, Business each year, fiscal year you want to make is to display
    the beginning of the fiscal year of April 1, always, the data,
    "OUTPUT_DATE" from April until March the following year.
    Currently being output error is as follows.
    :[nQSError: 22020] Function Subtring ( argument 1) does not support non-text types. (HY000)
    I want to fix logical SQL is as follows.
    case when substring("app_support"."TABLE_NAME"."OUTPUT_DATE" from 4 for 5)
    in ('04','05','06','07','08','09','10','11','12')
    then Cast
         Concat
    Substring(
                   Cast(
                        "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
              FROM 4 for 8
         '04-01'
    AS DATE
    when substring("app_support"."TABLE_NAME"."OUTPUT_DATE" from 4 for 5)
    in ('01','02','03')
    then timestampadd(SQL_TSI_YEAR,-1,
         Cast
         Concat
              Substring(
                   Cast(
                       "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
                   FROM 4 for 8
              '04-01'
    AS DATE
    For reference, logical SQL follows,
    there is no error, and it is operating normally.
    Cast
         Concat(
              Substring(
                   Cast(
                        "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
              FROM 0 for 5
         '-01')
    AS DATE
    I will grad to reply message.
    Thanks and regards.

    Dear Fame and all
    Hello.Thanks you for reply.
    Hi,
    You Missed END key word in the statement.Sorry,I mistake copy & paste only.
    So,The problem is still not resolved.
    The following shows, that the error has been corrected in the first message.
    Dear all
    I am Michel.
    When I was always trouble,
    everyone will go to support this Forum, I am glad.
    I want to fix Logical SQL about Expression Builder of Oracle BI 11.1.1.3.
    In detail, Business each year, fiscal year you want to make is to display
    the beginning of the fiscal year of April 1, always, the data,
    "OUTPUT_DATE" from April until March the following year.
    Currently being output error is as follows.
    :[nQSError: 22020] Function Subtring ( argument 1) does not support non-text types. (HY000)
    I want to fix logical SQL is as follows.
    case when substring("app_support"."TABLE_NAME"."OUTPUT_DATE" from 4 for 5)
    in ('04','05','06','07','08','09','10','11','12')
    then Cast
    Concat
    Substring(
    Cast(
    "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
    FROM 4 for 8
    '04-01'
    AS DATE
    when substring("app_support"."TABLE_NAME"."OUTPUT_DATE" from 4 for 5)
    in ('01','02','03')
    then timestampadd(SQL_TSI_YEAR,-1,
    Cast
    Concat
    Substring(
    Cast(
        "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
    FROM 4 for 8
    '04-01'
    AS DATE
    end
    For reference, logical SQL follows,
    there is no error, and it is operating normally.
    Cast
    Concat(
    Substring(
    Cast(
    "app_support"."TABLE_NAME"."OUTPUT_DATE" AS char
    FROM 0 for 5
    '-01')
    AS DATE
    I will grad to reply message.
    Thanks and regards.

  • How to get max date in variable using  dynamic query

    Hi,
    the following code gets all dates from sourcetable i want only max date , so i thought max function can be added and it will work
    but still i have to create a table for one value(scalar) can get it in any other effeciant way.
    declare
    TYPE date_string IS TABLE OF VARCHAR(1000);
    date_obj date_string;
    BEGIN
    EXECUTE IMMEDIATE 'SELECT to_char('''||day1||'-'||month1||'-'||year1||''') FROM '||source_schema||'.'|| sourcetable ||'' bulk collect INTO date_obj;
    FOR indx IN date_obj.FIRST..date_obj.LAST loop
    dbms_output.put_line(
    date_obj(indx));
    END loop;
    DBMS_OUTPUT.PUT_LINE('Sample output');
    END;
    yours sincerely

    944768 wrote:
    the following code gets all dates from sourcetableNo it doesn't. What is the datatype of day1, month1 and year1? They cannot be DATE datatypes otherwise your TO_CHAR would fail with all that concatenation going on. And your TO_CHAR is returning a VARCHAR2 datatype... so you cannot say that it is getting all dates... because there are no DATE datatypes returned. It's getting a lot of strings, but certainly not DATE's.
    i want only max date , so i thought max function can be added and it will work You can use the MAX function on a DATE datatype, but not on strings (at least not in the way you intend it to work).
    Converting it to a DATE before doing the MAX will allow you to get the maximum date (assuming the date format is correct)
    EXECUTE IMMEDIATE 'SELECT max(to_date(to_char('''||day1||'-'||month1||'-'||year1||'''),''DD-MM-YYYY'')) FROM  '||source_schema||'.'|| sourcetable ||'' bulk collect INTO date_obj;Then you will find have the other issues...
    a) you are then going to be fetching your DATEs in to a collection of VARCHAR strings. (Not even VARCHAR2, very poor). This should be DATE datatype
    b) you are bulk collecting into a collection, when you are using MAX which will return a single value in your example
    And you really should address the design issues:
    c) why are day, month and year, not being stored in the database as a single DATE datatype in the first place
    d) why does your code not know the name of the table it's querying requiring the use of very poor dynamic SQL techniques.
    e) why are you loading data in a collection in expensive PGA memory... what can't you do in SQL that requires you to collect the data into memory first?

  • Object type mappings in expression builder

    Hi,
    I'm trying to use expression builder to give me a query returning all instances of an object with a particular foreign key, and where 'active' = true.
    'active' is a CHAR field in the database with values 'T' or 'F' and this is mapped to a Boolean in workbench as true and false.
    All works fine in normal operations, retrieving and writing the data.
    I've written the expression as
    myId EQUAL arg
    AND
    active EQUAL 'true'
    where 'true' is a literal of type Boolean.
    Unfortunately, running this query generates an error that no mapping exists for 'true'.
    I've also tried changing it to
    active EQUAL 'T'
    where 'T' is a literal of type String.
    This also generates an error.
    It seems to me as though the object type mapping is confusing the expression builder and it can't generate the sql correctly.
    Any ideas?

    Can you post the specific version of TopLink, the exact code you are using to construct and execute your query, as well as the error message with stack trace. With these items we should be able to provide an answer for you.
    Doug

  • Validate Filter in Expression Builder of a Join Node

    Validating a filter query in the expression builder of a Join Node seems to take abnormally long.
    I'm mining a star schema with 1 fact table (750million rows) and 4 dimension tables. The join node merges facts and dimensions on a subset of the data that is specified in the filter query. The query is pretty simple:
    SUBSTR("L_PRESCRIBABLE_ITEM"."BNF_CODE" , 1,7 ) IN ('0601011','0601012')
    AND "L_LAST_DAY_TIME"."CALENDAR_YEAR" = '2010'
    When I press 'validate' it takes about 20 minutes to validate the syntax. When this completes successfully, when I press the OK button to get back to the Join Node, it seems to validate it for a second time, again taking about 20 minutes to complete.
    Is this something to do with the validation doing its processing on the raw data (i.e. the 750m rows x 4 dimension tables), rather than simply validating the structure of the query syntax? If so why is it doing it twice (not inculding the time taken to actually run the node).
    Cheers
    Brad
    Using Data Mining in SQL Developer 3.0.04

    Hi Brad,
    Actually the EA2 has an improvement but the final fix which uses strictly a parse validation, will be not be out till the next SQL Dev 3.1 release after EA2.
    Thanks, Mark

  • Expression Builder In Oracle Rule Authoe

    Hi,
    I am using expression builder for making this kind of expression:
    x = y* (new Double(.02))
    where x and y are Double.
    after inserting the variables and operator, validation always fails showing the following message:
    Cannot perform operation. 'RUL-01726: Data type operator for *, at position 10: java.lang.Double * java.lang.Double '
    Please tell me where i am going wrong. It's very urgent.

    Thanks for the reply Phil.
    I think that when I am updating datamodel, it is updating every thing in data model i.e. variables, constraints, functions, facts everything.
    Do you have knowledge of any method in the API which updates only variables??
    Also, i followed a different methodolgy be using RuleSession. have a look at code snippet:
    String rsrl ;
    * Double testValue = 6000.0;*
    * Double discount = new Double(0);*
    * try {*
    * rsrl = dict.ruleSetRL( ruleSetName );*
    * String dmrl = dict.dataModelRL();*
    * RuleSession session = new RuleSession();*
    * session.executeRuleset( dmrl );*
    * session.executeRuleset( rsrl );*
    * discount = (Double)session.callFunctionWithArgument("DM.calculateDiscount",testValue);*
    * System.out.println(" Discount "+discount);*
    * } catch (Exception e) {*
    * e.printStackTrace();*
    Here instead of updating dataModel i am executing ruleSet using session and callingFunction to calculate discount.
    Now if disocunt is populated independent of any other vairable (e.g. discount = 10.0d instead of discount = 10.0*salesValue)
    then it should work. But if discount is dependent on some variable (which has to be global Variable) then it would not populate it.
    This is what i have thought.
    But the above code snippets always give following exception :
    oracle.rules.rl.exceptions.InvocationException: wrong argument type in function or method invocation
    even when function takes arguments in my dictionary.
    Your help is much awaited!! Thanks in advance.

  • Using expression builder

    hi,
    how can i use where condition at expression builder at admin tool, can you share sytax please?

    Hi,
    Whenever you click on the expression builder the syntax will be shown to you as soon as you click on the functions or any object you select.
    In the logical table source, content tab, where clause, whatever condition you specify it gets reflected in the query when ever you pull the columns from the table.
    For example-
    If you are specifing the condition as
    Region_name='Asia'
    Then when ever you pull the columns from the table then the data will get restricted with 'Asia' data only.
    You can als call functions, session variables.
    Hope this helped/ answered.
    Regards
    MuRam

  • Expression builder Syntax question

    In workflow, I want to send an email when a certain date field is populated.
    I want this action to execute only when the date is initially populated so I want to use PRE to check to see if the date field was blank before it was populated.
    would I check to see if the date field WAS blank by using the following syntax?
    (PRE('<dContract_Execution_Date_ITAG>') IS NULL)
    Or should I use
    (PRE('<dContract_Execution_Date_ITAG>') = "")

    Thank you I will try your suggestions. I tried the IS NOT NULL and I kept getting a syntax error. It was driving me nuts, because I was fairly certain it would work.
    This is a little off topic, but I've noticed when I enter an expression or copy paste it into expression builder I get a syntax error only to retype the expression (exactly as it was typed previously) and the system will except it. The only thing I can think of is maybe some sort of invisible character is picked up.
    This has happened to me numerous times when coding workflow rules. It tends to slow the design process.

  • Expression builder in BPEL

    Im trying to manipulate a file name at runtime. Right now I have the inbound header mapped to the outbound header so that the file gets to its destination with a dynamic filename. We are picking up multiple files Ex. KL* and the customer wants the same file name as was picked up. So anyway now they want it picked up as a .dat file and dropped off as .txt
    I am lokoing through the expression builder via jdeveloper and see there are many funtions. From the looks of it there is something to modify this extension i want to change but im having a hard time finding one or documentation explaining what each of these functions do
    any help please

    Well assuming the below would be my Xpath statement because there is no statement in here that says read a specific file.txt it is read in in dynamic what i mean is we say pick up DEF*.dat so we want any DEF.dat to get read in but at the same time we want the original name stay on the file as it gets processed. So we may have DEF123, DEF456, DEF789 get read in but they will keep their file names as going through
    <variable name="Inbound_Head" messageType="ns3:InboundHeader_msg"/>
    So first off when creating variables i never knew there was a way to make a "temp variable" so if I could create a "temp" one then
    concat(substring(bpws:getVariableData('gdotltest.dat')), 1, string-length(ns3:InboundHeader_msg('gdotl.dat')) -3 '.dat')
    ok and then when you are saying
    "First save your fileName " Are you saying the name as the file name i want as in right now it is gdotltest.dat
    are you saying assign the variable for ns3:InboundHeader_msg as 'gdotltest.dat
    I am sort of seeing where you want to to go with this just help me out a little more if you could
    So i got this variable that is associated with DEF*.dat filename right
    Ex. ns3:InboundHeader_msg = DEF*.dat
    So then i want to create a temp variable name something like ns7:InboundHeader_msg_TempVar <--------- just saying for example correct me on any syntax error and im going to want to associate this variable i made up with DEF*.txt so that when my bpel interacts with this hmmmmmmm thinking about this now how will this keep the dynamic file naming convention still going if now im associating a new variable with a file coming throguht that is suppose to keeps it s name ? Sorry to sound confusing but explain one last time how we are keep the first half of the file name dynamic and making the .dat or .txt or .doc unique to just output as .dat ?

  • Expression builder functions

    It looks like there is no support for UPPER or LOWER string functions in the expression builder ... is this correct?

    Additional information: If you cut/paste an expression from the expression builder calling a jar function into a report,although you cannot see the functions in the expression builder of the report and run the report on the server , the function call will return the correct data without error. This is a 4.3.1 report with the 4.3.1 Runtime using Apache 7.0

Maybe you are looking for

  • Issue in reading the XML file

    Hi Gurus, I am dier need of one of the xml issue which I am facing right now. I am reading one of the xml file which is like this <?xml version="1.0" encoding="UTF-8" ?> - <GEBIZ_ORDER xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <HEADER>

  • List Output - how to position cursor back to Page 1, line 5, column 90.

    Hello, I have a report program that calculates and writes a Grand Total at the end of a multiple page report. The program can not calculate the Grand Total until the end of the program.  Pages are displayed as Subtotals are calculated. My user wants

  • Getting the runtime environment to see packages in the jre/lib/ext dir

    I've downloaded mysql-connector-java-3.0.6-stable-bin.jar so that i can connect to a mysql database. I can use it fine from tomcat, but when I try and write stand alone stuff I get java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.U

  • KER1-Changes not update in KE30

    Hi folks, i have sa problem with KER1. I have done a change on existing key figure scheme. I have added in a element formula 5010  a new element 9002. Now the formula is 9001+9002. I have saved, now i want to now why in KE30 i don't see any changes,

  • Making a delete commit automatically with ADF BC, Struts and ADF UIX

    I'm trying to create a delete action that commits to the database automatically using ADF Business Components, Struts and ADF UIX. I have a browse page from which the user can view all records in the table, and perform edit, create and delete actions