[MDX] Define date range based on user selection

Hi All,
I'm trying to define date range (of 3 months) using mdx based on user selection.
This is what I'm trying to do:
- If user select 2013, I would like range to be: from
1 Oct 2013 to 31 Dec 2013
- If user select Aug 2013, I would like range to be: from
1 Jun 2013 to 31 Aug 2013
- If user select 15 Sep 2013, I would like range to be : from
15 Jul 2013 to 15 Sep 2013
It is not a problem to get the upper bound of the range like this:
ClosingPeriod(
[Date].[Calendar].[Date],
[Date].[Calendar].CurrentMember
But I'm not able to get the lower bound of the range:
OpeningPeriod(
[Date].[Calendar].[Date],
ParallelPeriod(
[Date].[Calendar].[Month Number],
2,
ClosingPeriod(
[Date].[Calendar].[Date],
[Date].[Calendar].CurrentMember
Error:If user selection is
15 Aug 2013, I get
14 Jun 2013
If user selection is Apr 2013, I get
(null)
And even more strange, if user selection is
2013, I get 28 Oct 2013
Any idea of how to solve this ?
Thanks,
Guillaume

Hello Guillaume,
Can you please check if the following works for you? By the way, the performance will suffer due to all these IIF, the solution is very complex in order to avoid null in ParallelPeriod.
with member measures.high as MemberToStr(ClosingPeriod(
   [Date].[Calendar].[Date],
   [Date].[Calendar].CurrentMember
member measures.low as
MemberToStr(
iif(ClosingPeriod(
   [Date].[Calendar].[Date],
   [Date].[Calendar].CurrentMember
) IS ClosingPeriod(
   [Date].[Calendar].[Date],
   [Date].[Calendar].CurrentMember
).Parent.LastChild  --last date of the month
OpeningPeriod(
   [Date].[Calendar].[Date],
Ancestor(ClosingPeriod(
   [Date].[Calendar].[Date],
   [Date].[Calendar].CurrentMember
), [Date].[Calendar].[Month]).lag(2)
iif([Date].[Calendar].CurrentMember.level is
[Date].[Calendar].[Date]
and
Right(CSTR([Date].[Calendar].CurrentMember.Properties("KEY0")),4)="0429" --take care of 4/29
OpeningPeriod(
   [Date].[Calendar].[Date],
Ancestor(ClosingPeriod(
   [Date].[Calendar].[Date],
   [Date].[Calendar].CurrentMember
), [Date].[Calendar].[Month]).lag(2)
OpeningPeriod(
   [Date].[Calendar].[Date],
   ParallelPeriod(
      [Date].[Calendar].[Month],
      2,
      ClosingPeriod(
         [Date].[Calendar].[Date],
         [Date].[Calendar].CurrentMember
select  {measures.low,measures.high } on 0
from [Adventure Works]
where
--[Date].[Calendar].[Date].&[20070815]
--get [Date].[Calendar].[Date].&[20070615]
--[Date].[Calendar].[Date].&[20070530]
--get[Date].[Calendar].[Date].&[20070330]
--[Date].[Calendar].[Date].&[20070429]
--get [Date].[Calendar].[Date].&[20070201]
--[Date].[Calendar].[Calendar Year].&[2007]
--get [Date].[Calendar].[Date].&[20071001]
--[Date].[Calendar].[Month].&[2007]&[4]
--get [Date].[Calendar].[Date].&[20070201]
--[Date].[Calendar].[Month].&[2007]&[5]
--get [Date].[Calendar].[Date].&[20070301]
--[Date].[Calendar].[Date].&[20070228]
--get [Date].[Calendar].[Date].&[20061201]
--[Date].[Calendar].[Date].&[20070831]
--get [Date].[Calendar].[Date].&[20070601]
If this does not work for you, I would suggest opening a ticket with Microsoft Support, with an advisory type of request.
Hope this helps.
Thanks.
Meer Al - MSFT

Similar Messages

  • Output different data based on user select

    Hi everyone,
    Quick question, I would like to output different report columns based on user select, eg., users would be presented with two choices in a radiobutton list, eg., 1 and 2.
    I have query results that contain columns A, B, C, D, E, F, G.
    If user selects 1 then the output should be columns A, B, C, D, E.
    If user selects 2 then the output should be columns A, B, C, F, G.
    I am sure this is possible and easy? If so, what topic should I be reading/searching internet on?
    Please advise.
    Thanks!

    I would say that this is most often something that your user interface should be dealing with (i.e. which columns should be shown).
    There is no way to do that in SQL.
    In PL/SQL it is a simple situation of creating two cursors and simply deciding which one to open.
    <pre>declare
    l_cur sys_refcursor;
    begin
    if :user_selection = 1 then
    open l_cur for select A, B, C, D, E from tbl;
    else
    open l_cur for select A, B, C, F, G from tbl;
    end if;
    -- use the cursor
    close l_cur; -- or return to user interface
    end;
    /</pre>
    Hope this helps.

  • How to create dynamic ed flash charts based on user selected fields in Orac

    Hi all,
    Can any of the experts please tellme "how to create dynamic ed flash charts based on user selected fields in Oracle apex".
    Thanks
    Manish

    Hello,
    Lots of different ways to do this, I blogged about one way (using a Pipelined function) here -
    http://jes.blogs.shellprompt.net/2006/05/25/generic-charting-in-application-express/
    Other options include using a PL/SQL function returning the string to use as the dynamic query etc.
    Hope this helps,
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • Creating report based on user selected Date Range

    Hello.
    I am trying to display an Apex report that selects data for the report based on a user entered date range.
    It's a simple page with two date picker fields (p18_start and p18_end).
    The report region SQL looks like this:
    SELECT *
    FROM prj_items
    WHERE LM_DT BETWEEN :p18_start AND :P18_end
    One table, one field on the table to search and two Apex variables.
    I thought this would be fairly simple, but I am obviously missing something.
    I not even sure what other information is needed to help me figure this out.
    -Jody

    Hi,
    You can set defaults for the datepickers if you need to - this could be done in a computation on the page for each item and conditional on the item being null.
    When I've done something similar to this, I've created two hidden page items - eg, :P19_FIRST_DATE and :P19_LAST_DATE and populated these with the earliest/latest date that the user could reasonably select (perhaps, in your case, the MIN(LM_DT) and MAX(LM_DT) values).
    Then your SQL would be:
    select * from PRJ_ITEMS
    where LM_DT BETWEEN TO_DATE(NVL(:P19_START,:P19_FIRST_DATE), 'DD-MON-YY')
    AND TO_DATE(NVL(:P19_END,:P19_LAST_DATE), 'DD-MON-YY')If you don't want to set default dates, you could do something like:
    SELECT * FROM PRJ_ITEMS
    WHERE (:P19_START IS NULL AND :P19_END IS NULL)
    OR (:P19_START IS NOT NULL AND :P19_END IS NULL AND LM_DT >= TO_DATE(:P19_START,'DD-MON-YY'))
    OR (:P19_START IS NULL AND :P19_END IS NOT NULL AND LM_DT <= TO_DATE(:P19_END,'DD-MON-YY'))
    OR (LM_DT BETWEEN TO_DATE(:P19_START,'DD-MON-YY') AND TO_DATE(:P19_END,'DD-MON-YY'))There are various reasons why your two dates are being cleared when the page is reloaded. Firstly, you should check the branch that returns to the same page - make sure you are not clearing the cache for the page. Then, have a look to see if there is a "reset page" process (usually created for you when you create a form page). Then, check the Source settings for the items. Typically, these would be "Only when current value in session state is null" and a Source Type of "Static Assignment" with the "Source Value or Expression" left empty.
    Andy

  • User defined date ranges in Analyzer

    is there a way in Analyzer to allow users to define a range of dates for which to see results ? (i.e. from mm/dd/yy to mm/dd/yy)

    Hai!
    What is PO report?
    where it is?
    Is that your query Report? If so Please provide the query.
    we can't bring extra fields in to SAP Default Reports.
    Regards,
    Thanga Raj.K

  • How to update records in a table based on user selection..

    Hi all,
    This time the above doubt is totally based on the logic of coding which I tried a lot but didn't get any solution. so atlast I come to sdn site.
    please help..
    The requirement is like that I have a table with 6 fields (1 primary key and other are nonkeys). If the user inputs some values in the fields on the screen, then a row will be added in the table. Upto this i have done well. but when the user want to change some value  in the existing row of the table my program unable to do so. Because I couldn't get any logic to do that as there are 5 nonkey fields, so if any one field is modified then the respective row should be selected first based on the user selection and then it should be updated.
    At this point I could not get any idea as it may take a lots of if conditions (I guess) to reach to that particular row.
    Please help..
    thanks ,
    sekhar

    Hi Sekhar,
    I am afraid, the whole design of your program is wrong, let me explain
    Let us say you have two rows(5 non key fields) that the user wants to update and the data in these five non key fields are identical and in your program you are getting a number(which is the key) using a number range object. So you will have two entries in the table for the same data.
    And on the update page when the user enters the non key fields, how will the program know(or for that matter any one of us) which record to pick, if you have two identical books and if asked for a book wouldn't you ask which one among these two do you want?
    Possible Solution: Identify a possible key maintaining the integrity of the data, that is a combination of the non key fields which will help you identify a unique row and make these fields as key fields in the table.
    A more costly solution(if you do not want to change the non key field keys to key fields) would be to, adding a check(using select statement) to see if the non key fields combination already exists in the Z table before inserting a record into the table.
    If yes, throw a message to the user and just update the values in the table, else insert the record.
    Another solution would be to, use the non key fields to generate a key(using some logic) and using this instead of the number range object.
    regards,
    Chen

  • Reading dynamic table column based on user selection

    Hi there,
    I am having a problem of reading and manipulating the data stored in a standard SAP table. The following example simulates the table and what i am trying to do:
    Table: Storing sales data for sales person
    SALES_PERSON    REGION   YEAR   MTH_S1  MTH_S2  MTH_S3 MTH_S4...
    Richard  S               NORTH    2007     100          200         300        400
    John K                    SOUTH    2007      50           100         100        20
    Brad P                    NORTH    2007     300          100         100        50
    User have have the following selection option:
    1. Month.
    The program will calculate the sales based on the individual month selected
    Example, if user select Month = 3, then program take only MTH_S3 column value
    So total sales = 300100100=500
    2. Month range
    The program will calculate the sales based on the month range selected
    Example, if user select Month 2 to 4, then program take MTH 2 to MTH_S4 columns value
    So total sales = 400 (for MTH_S2) + 500 (for MTH_S3) + 470 (for MTH_S4) = 1370
    How should i write the logic or code for this requirement?
    Hope someone can help.
    Thanks,
    Pang HK

    Try something like this
    TABLES:
    t247.
    SELECT-OPTIONS:
      s_month FOR t247-mnr NO-EXTENSION.
    DATA:
      BEGIN OF fs_data,
        person(30),
        area(10),
        year(4),
        mon1 TYPE kbetr,
        mon2 TYPE kbetr,
        mon3 TYPE kbetr,
        mon4 TYPE kbetr,
        mon5 TYPE kbetr,
      END OF fs_data,
      t_data LIKE STANDARD TABLE OF fs_data,
      w_no_months TYPE i,
      w_kbetr TYPE kbetr,
      w_total TYPE kbetr.
      LOOP AT t_data INTO fs_data.
        CLEAR w_kbetr.
        DO 5 TIMES VARYING w_kbetr FROM fs_data-mon1
                                                          NEXT fs_data-mon2.
        IF sy-index IN s_month.
          w_total = w_total + w_kbetr.
        ENDIF.
        ENDDO.
      ENDLOOP.
    change the value 5, according to the no.of months in ur internal table

  • Creating a Parameter with pre-defined date ranges.

    How can I create a parameter that will allow the user to select a specific date range for a report (i.e. YTD, MTD, WTD...)? Any suggestions? Thanks...
    Matt Johnson

    You can create & define Parameters in SSRS Report and provide possible values (MTD, YTD or WTD) as drop-down options, the user can then select which one to pick and you can write your T-SQL logic to capture this option and take further query action
    on it
    Good Luck! Please Mark This As Answer if it solved your issue. Please Vote This As Helpful if it helps to solve your issue

  • APEX4: How to create a report whose data is based on user input date fields

    Using Apex 4 I've to create a report that allows the user to input two date and shows a report between the date range.
    How can I do this?
    Thank you.

    This has nothing to do with apex 4.0. If you create a report using this query:
    SELECT *
      FROM emp
    WHERE hiredate BETWEEN NVL (TO_DATE (:p1_date_from, 'mm/dd/yyyy'), hiredate)
                        AND NVL (TO_DATE (:p1_date_to, 'mm/dd/yyyy'), hiredate)and create two date picker items with names P1_DATE_FROM and P1_DATE_TO (take care of using the right date format), your report will show all records by default and those that match after you fill in the date items.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • Variable Exit - Last Three months date range based on Sy-datum

    Hi
    I have a requirement to filter last 3months data based on sy-datum. I have a variable filter on Posting Date.
    For e.g. Today is 20110622
    I have to determine below range: When users run the report prompt should be auto filled with below date range.
    From Value: 20110301
    To Value     : 20110531
    From sy-datum I can find the first day of the current month - In this scenario 20110601 (I'll replace last 2 characters with "01").
    If I subtract "-1" I'll get the To Value: 20110531
    Question is to get the "From Value". If I subtract 90days from To value, it will work for few months.
    For e.g. If my To value is Feb 28th and if I subtract 90days, I may get a different answer.
    Is there any better approach to determine this date range?
    Thanks for your help.
    Best Regards,
    Sree

    Hi Sree,
      Pleae find this approach and compare
    data : l_date type sy-datum,
    l_startdate type sy-datum,
    l_endate type sy-datum,
    l_startmonth(6) type c,
    l_endmonth(6) type c,
    l_date = sy-datum.   say "20110622
    l_endmonth = sydatum(6)   "201106
    Pass year month and get previous month using this standard .
              CALL METHOD cl_rs_time_service=>shift_year_month
                EXPORTING
                  i_year_month = l_endmonth
                  i_shift      =  -1
                RECEIVING
                  r_year_month = l_endmonth
                EXCEPTIONS
                  failed       = 1
                  OTHERS       = 2.
    "l_endmonth = 201105.
              CALL METHOD cl_rs_time_service=>shift_year_month
                EXPORTING
                  i_year_month = l_endmonth
                  i_shift      =  -2
                RECEIVING
                  r_year_month = l_startmonth
                EXCEPTIONS
                  failed       = 1
                  OTHERS       = 2.
    "l_startmonth = 201103
    l_startdate(6) = l_startmonth.
    l_startdate+6(2) = '01'.
    "l_startdate = 20110301
    We got startdate in and we want to get enddate , but we got endmonth ...
    now we need to get last date of the endmonth.
    Use this function module SLS_MISC_GET_LAST_DAY_OF_MONTH  and u can get it. Input should be date.
    so put l_enddate+6(2) = '01'.
    l_enddate(6) = l_endmonth.
    now pass end date to the  Function module and this will return the end date of the month.
    So you get l_startdate and l_enddate as you require. This will work for leap years or feb 28 days what ever...
    Regards
    vamsi
    Edited by: vamsi talluri on Jun 22, 2011 10:06 PM

  • Month filter between two ranges based on user response inIDT

    Hi,
    I am working on SAP BO4.0.I have a requirement of creating a month filter on a date which will be between two ranges.The first range is the user response and the second range will be 6 months added to that user response.For eg:-If a user enters 1 as the response for month prompt then the date will be filtered between 1 and (1+6)=7.The database used is SAP HANA.
    Please let me know if further clarifications are required.
    Any help on this will be appreciated.
    Thanks in advance.

    Hi Riddhi ,
    afaik this is not doable in UDT/IDT .Only thing we can make is to run the report for last month by using magic dates concept.
    Check below logic if it helps.
    For a requirement to run a report for  fiscal year starting date to last month if nothing selected .
    @Select(Time\Yr-Mth Key)  between@Prompt('From Date','A','Time\Month / Year',mono,primary_key,,{'JUL 2013'}) and   
    (case when @Prompt('To Date','A','Time\Month / Year',mono,primary_key,,{'JAN 1999'})='JAN 1999' then to_char(add_months(sysdate,-1),'YYYYMM')  
    else  
    @Prompt('To Date','A','Time\Month / Year',mono,primary_key,,{'JAN 1999'}) end)
    This is on Oracle Database.
    When you run webi report
    From Date : JUL 2013 (fiscal year start date)
    To date : JAN 1999( without changing this you can refresh the report for last month , else it'll refresh for selected month)

  • How to HIde rows based on User Selection

    I have a requirement where in I have to hide some rows based on Plant Name selected by USer at the time of opening the report.
    Here is the screen  shot:-
    Here I am seeing two Tag Types MACT and Average when User selects  Luling Plant. But When User selects some other Plant I don't want to see Tag Type 'MACT' in this table.
    We have a predefine filter for Plant.
    How can I achieve that. The data in White Rows is Average values.
    Please help.
    Regards

    Hi Shalini,
    Is user selecting Plant Name from the report prompt. If Yes, then try below-
    Create a variable-
    FilterSelect= If UserResponce("WritePromptTextHere") =" Luling Plant" and TagType inList ("MACT";"Average") Then 1 ElseIf  UserResponce("WritePromptTextHere") <>" Luling Plant" and TagType inList ("MACT";"Average") Then 3 Else 2
    Apply Filter on "FilterSelect" variable-
    FilterSelect=1 and 2
    ~Anuj

  • Dynamic dropdown based on user selection of another dropdown on the same page

    hi all, ok, I have a table which contains use data, a name,
    and a userID. for the example lets say "Simon Bullen" and my userID
    is "999".
    on a form I have, there is a dropdown box, which is dynamic
    from this table, and allows me to select Simon Bullen, however, I
    have a hidden field on the form, which when the user selects "simon
    bullen" the hidden field populates with the appropiate U number
    from the same table.... no i thought this would do it:
    <cfquery name="userNumber" datasource="userList">
    SELECT userNumber FROM dbo.Users WHERE Name =
    <cfqueryparam value="#form.Name#">
    </cfquery>
    and then my dynamic form field (hidden) would reference to
    this query....
    but it doens't work, could somebody please enlighten me? I'm
    hoping its something silly
    Thanks in advance

    You could make the value of the option the UserID and the
    option display the name.
    If that isn't what you need, I think you'll need some
    javascript to populate your hidden field based on what is chosen in
    the select.
    I think you can modify this:
    http://www.javascriptkit.com/javatutors/selectcontent2.shtml
    ...to populate your hidden field instead of a new select
    list.
    If there's a way to do that without JS I'm not aware of it.
    A third possibility: look up the UserID (based on the name
    chosen) after the form is submitted then do with it whatever you
    need to.

  • Tablix Data mapping based on parameters selected.

    I ahve a report that is for variable based on the parameters selected. Parameter 1 is TableName, it lets the user select the table from the database that they would like to see the clolumns for. From there the second parameter is the Column names from the
    table that was selected. I can get the headers to show based on the selection but not the actual data.
    I've got this query that i created in SQL that works if input the parameters but i cannot figure out how to tie in the data to the report tablix.
    DECLARE @Column_Name VARCHAR(500)
    DECLARE @Table_Name VARCHAR(100)
    DECLARE @sql_str VARCHAR(500)
    SET @Column_Name = 'Id,Sort,Brand'
    SET @Table_Name = 'Item'
    SET @sql_str = 'Select ' + @Column_Name + ' FROM ' + @Table_Name
    --SELECT @sql_str
    EXECUTE (@sql_str)

    but i cannot figure out how to tie in the data to the report tablix.
    You can not dynamically assign the column to a text box (tablix). The best way is to modify your SQL to return the result with a fix column alias, then you can assign ths column to the Report control =>
    SET @sql_str = 'Select ' + @Column_Name + ' AS [ReportColumn] FROM ' + @Table_Name
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Using Date Range parameter in Subreport Selection Formula

    I have a subreport which includes this line in the selection formula:
    {Production.Date} = {?Pm-?DateRange}
    {?Pm-?DateRange} appears in the Subreport Links window, so it seems like it should work.
    The DateRange parameter is set by the user in the Main report.
    But the subreport returns no records.
    I tried this:
    In the Main report I created a StartDate and a StopDate field from {?Pm-?DateRange} .
    Then in the subreport selection formula I used these two formula fields like this:
    {Production.Date} >= @StartDate
    and
    {Production.Date} <= @StopDate
    This works!
    So I have found a workaround, but still, I don't understand why the original code {Production.Date} = {?Pm-?DateRange} returns no records.
    Thanks,
    Art

    Hi Art,
    You cannot use a date range parameter directly in the subreport's record selection formula.
    You'll need to create a formula in the Main report like this:
    Minimum(?DateRange) //This gives the start date
    Maximum(?DateRange) //This gives the end date
    Then send these formulas as parameters to subreport for use in the record selection formula.
    I think you've already got this figured out anyway!
    -Abhilash

Maybe you are looking for

  • Can't move objects?

    I cannot figure out what's going on with my InDesign. I can't select any object, text or path, and move it by dragging. I can move it by nudging with the arrow keys, but dragging does not work. I've restarted, trashed preferences, etc, and it just wo

  • How to update something on different JFrame...?

    Hi! How can you update a component on a JFrame different from the one where the action is performed? I ve tried passing a reference of that frame and invalidating anything possible... but did not work! I desperatly need help! Do you have any example?

  • WBS in report RFLQ_LISTIT

    Hello Gurus How we can implement or add additional fields to the line items shown in Cash and Liquidity Planner? We would like to show profit center and WBS in line itens report, report RFLQ_LISTIT. Regards JLeal

  • How Noisy Should a MacBook Be?

    I have the grandaddy of all Macbooks - a 1.83 Core Duo - that I've been ignoring for some time. But recently, I decided to extend its life a bit by upgrading to an SSD (a great decision BTW). The MB still serves my needs well, but there's one thing t

  • Do I need Internet to use find my iphone

    I'm trying to use find iPhone , we have three phones on our AT&T account. It's been working fine. Today I blocked data to the teen on our plan and now I can't track her phone. AT&T said I do not need Internet connection to use this feature . I'm not