MDX to return last month of a quarter

I have an MDX query where I need to return the last month of a quarter going back 2 years or 8 quarters.  I want the results to be like:
Q1 2012   March 2012    #####
Q2 2012   June 2012      #####
Q4 2013   Dec 2013     #####
I"ve tried this:  TAIL(Descendants(Lastperiods(8,STRTOMEMBER(@DataDate)), [Product Post Date].[Calendar].[Month] ),1 )
but it's only returning the last monthe for the last Quarter and I need the last month for the last 8 Quarters.
What am I doing wrong here ?   Thanks.
J. Way

You're welcome Judy!
I'll do my best.  I think the simplest way to conceptualize the generate function (in this case, not the string concatination case for which it can also be used) is ...
For each tuple/member in the first set (passed as a param), "apply" the 2nd set param to it.
Union all the results together, and thereby "generate" a new set.
What makes it useful is you can use CurrentMember to explicitly refer to members from the 1st set when doing this.
Consider the following example ...
As discussed in the
MSDN definition, it is often used with TOPCOUNT.  If you need to show the top 10 products sold in each particular calendar year, generate a new set that for each year, derives the top 10 products, and then union all the results together into a newly
generated set.
Copy/paste from MSDN:
---------------------------------copy/paste start:
The following example query displays the top 10 Products for each Calendar Year on Rows:
SELECT
{[Measures].[Internet Sales Amount]}
ON 0,
GENERATE(
[Date].[Calendar Year].[Calendar Year].MEMBERS
, TOPCOUNT(
[Date].[Calendar Year].CURRENTMEMBER
[Product].[Product].[Product].MEMBERS
,10, [Measures].[Internet Sales Amount]))
ON 1
FROM [Adventure Works]
Note that a different top 10 is displayed for each year, and that the use of Generate is the only way to get this result. Simply crossjoining Calendar Years and the set of top 10 Products will display the top 10 Products for all time, repeated for each year,
as shown in the following example:
SELECT
{[Measures].[Internet Sales Amount]}
ON 0,
[Date].[Calendar Year].[Calendar Year].MEMBERS
TOPCOUNT(
[Product].[Product].[Product].MEMBERS
,10, [Measures].[Internet Sales Amount])
ON 1
FROM [Adventure Works]
---------------------------------copy/paste end
I hope that helps!
Christian Wade
http://christianwade.wordpress.com/
Please mark correct responses as answers!

Similar Messages

  • How to get the sales value of the last month in the quarter

    Hi,
    We have a requirement to get the "Sales" value against a quarter. We have 2 tables "Time" and "Sales". We want to display the Sales value against each quarter.
    But this should happen as follows.
    Consider quarter Q1 it should display the value of 3rd month, Q2 should display value for 6th month and so on..
    If in any particular Quarter we dont have a value for last month then it should display the value for 2nd month, if 2nd month value is also not present then it should display 1st month sales value.
    We are using excel as the database.
    Please let us know if anybody has a resolution to this.
    Regards,
    Apoorv Chitre

    hi,make an other column which will be the flag for the last months you want to be displayed...
    so ,in reports,you pass it as hidden column(by filter only the ones which have the appropriate flag),and then voila...
    i hope i helped
    http://greekoraclebi.blogspot.com/
    ///////////////////////////////////////

  • Want last month value of a Quarter instead of to-date value

    Hi All
    I have a report that has 2 columns : Quarter-year , Measure1. Quarter-Year can be drilled down to the month level. Now, what is happening is because I only have the Quarter-Year as the dimension column, I'm getting the cumulative (todate) value for the measure. Say I have Q1-2010 drills down to Jan - 10,000 .. Feb-20,000.. Mar-30,000... I want the report
    to show the value as of March (the last month of the quarter): Q1-2010     30,000.
    Instead I see the value as (10k+20k+30k = 60,000). Is there a way of achieving 30,000 value for Q1-2010 in Answers?
    Thanks
    Ananth
    Edited by: Ananth V on Feb 4, 2010 8:54 AM

    Excuse the re-edit, the instructions below will give you a level based measures. if you used function QUARTER_OF_YEAR(expr) you should be able to use a case statement below to only pull Quarters 3, 6, 9 and 12 (ie last quarters) in your measure definition, then use the level based mechanism if required.
    Create another measure (duplicate your existing) and set the level of this measure to 'Quarter' by editing content tab on that measure or dragging it up to the Quarter level in your date hierarchy.
    This will return the Quarter total , regardless of group by- you may need to set other levels in accordance with other dimensions used on the report.
    Hope this helps,
    Rgrds
    Alastair
    Edited by: Alastair_PeakIndicators on Apr 26, 2010 4:12 PM
    Edited by: Alastair_PeakIndicators on Apr 26, 2010 4:13 PM

  • Line Chart - Current Year Sales, Current year Returns, Last year Sales, Last Year Returns

    We have a report that summarises monthly sales & credits for 2 years in a group footer.   The footer is a sum of a formula in the detail section that calculates the monthly sales at the Item code level
    Item 1
    Group Footer 1     July     Aug     Sept     Oct          
    Sales Last Yr     @July_LY_Sales @Aug_LY_Sales     @Sep_LY_Sales  @Oct_LY_Sales          
    Credits Last Yr @July_LY_Credits @Aug_LY_Cred     @Sep_LY_Cred   @Oct_LY_Cred          
    Sales This Yr @July_CY_Sales @Aug_CY_Sales     @Sept_CY_Sales @Oct_CY_Sales          
    Credits This Yr @July_CY_Cred @Aug_CY_Cred     @Sep_CY_Cred @Oct_CY_Cred          
    <Curr Yr Graph1>
    <Last Year Graph2>
    Item 2
    Group Footer 1     July         Aug           Sept                               Oct          
    Sales Last Yr  @July_LY_Sales   @Aug_LY_Sales @Sep_LY_Sales @Oct_LY_Sales          
    Credits Last Yr @July_LY_Cred  @Aug_LY_Cred     @Sep_LY_Cred @Oct_LY_Cred          
    Sales This Yr   @July_CY_Sales  @Aug_CY_Sales     @Sept_CY_Sales @Oct_CY_Sales          
    Credits This Yr    @July_CY_Cred   @Aug_CY_Cred     @Sep_CY_Cred @Oct_CY_Cred          
    <Curr Yr Graph1>
    <Last Year Graph2>
    In the footer under the data, we want a 4 line graph (or 2 x 2 line graphs for this year & last year).  One line for sales for the current 12 months, and with it, a line plotting the credits, so as to see the trend over that year.  And then we want a line graphing the previous years sales and a line graphing the previous year credits for the 12 months. 
    On the data tab in chart expert, we selected the Place chart for each SHDOC.ITEM (Item number) in the footer and this is positioning correctly.  We have tried selecting "On change of shdoc.item and we have also tried For each record.  We selected on change of shdoc.item to generate the graph for each item.  We then added the 12 formula for the current year in the Show Value panel  
    In the show value panel we tried using the detail formula, the Report Area: Sum of <formula> and the Group 1: Sum Formula.  They all display as @July or @Aug which is a dependent formula used to identify the month
    We have added the above formula for each month and each value, but we can't work out how to group the monthly data into the 4 series of 4 lines (1 colour each) - Current Year Sales, Current Year Returns, Last Year Sales, Last Year Returns for the charting.  We have tried to create a graph with only 1 set of monthly data (viz, just 12 months current year sales) But no matter what options we take, we seem to get 12 line chart representing each month rather than 1 line representing 12 months.
    Can someone point us in the right direction?

    Please re-post if this is still an issue but search forums first, lots of chart questions have been answered.

  • My iPhone is about 6 months old now and I would say I don't use it that much. Yet for the last month or so the battery life has been going down and today after having charged it to 100% this morning, it was at 5% at 4 pm this aft. help!!

    my iPhone is about 6 months old now and I would say I don't use it that much. Yet for the last month or so the battery life has been going down and today after having charged it to 100% this morning, it was at 5% at 4 pm this aft. help!!

    Ok Fellas, let me give you a clue:  Games, particularly those that make heavy use of graphics and sound are notoriously power hungry.  In fact, when I was in the Navy many years ago, the folks working on the NTDS (Navy Tactical Data System)  computers used a version of Space Invaders to load test the AN/UYK-43 computers.
    I have also noticed that all of my laptops (I have a brand new Toshiba dual core, an older Toshiba single core, plus 2 Dell dual core machines) have significantly shorter battery life when I play Company of Heroes than when I am just reading e-mail or surfing the 'Net.  I have also noticed the same behavior when I play games on my 4th gen Touch and my iPhone 4.
    The fact is, iOS 5 did make some major improvements as well as adding some nice functionality like iMessage, wireless synch, and such, but the down side is that depending on how you use the device battery life can be shorter that what you may have experienced with pervious versions of iOS.  Its just the nature of the beast...
    We now return you to our regularly scheduled programming.....
    Oh John....  Oh Marsha.....

  • The events of the last month have suddenly disappeared.  I have opened these successfully several times during the last few weeks, but on opening them yesterday they weren't there any longer. No idea how this could have happened! Possible to retrieve ???v

    The events of the last month, with the photographs have suddenly disappeared from the iPhoto Library.  I have opened these successfully several times during the last few weeks, but on opening them yesterday they weren't there any longer. No idea how this could have happened! Is it possible to retrieve ???

    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • Identifying same values that existed previously (last month)?

    I am creating an OBIEE usage report and need help with a complex Column Formula.
    I want to identify returning users, that logged in this month AND last month.
    This logic might be something like:
    CASE WHEN User ID exists in Current Month = User ID that existed in the Previous Month then 1 else 0
    I have Month and User ID columns to work with in OBIEE Answers (no RPD access).
    Any idea of how to right a formuala that will compare non-measure values from last month to this month?
    Thanks!

    Roman,
    You can push down your current month and last month logic into Analytical view.
    In Time Attribute view, create two claculated measure for calender month. You can build this using "NOW" function, left functions. Once you have current month create last month leveraging current month and casting (current month -1)
    Once you have these two calculated attribute ready in your Time attribute view. Bring it to Analytical view and using "if then" function you can calculate measures for Current Month and Last Month.
    This will improve performance as it avoids jumps between various engine.
    Thanks

  • How to display records based on current month and last month???

    i have a query that want to display the data for current month and last month. when i try to view the reports, all the data/key figures is return all in 0.00.
    i modify the variables for this current month and last month but still the results is the same. i could not see the data. any advise on how to modify the variables for this current month and last month? i am thinking my variables is wrong.
    for the current month variable:
    the type of variable is characteristic value, processing by customer exit, reference characteristic is calendar year/month.
    thanks for all who are kind to help me here....

    Hi,
       If you install the variables from BC correctly and they are in active state, you can use them directly use them. check for this month the total values at info cube is ZERO or some value. as you told you are getting ZEROS for your input.and check the data at cube level based on your query design, apply all restrictions, fileters and see do you get any data at cube level and compare with report.

  • Help:  Last Month Last Day till 12:00:00 PM

    Hello Folks,
    I am trying to get the last months last day in the query for developing a report. I have tried the code as below
       TRUNC (SYSDATE, 'MONTH') - 1  but it returns
    11/30/2009 12:00:00 AMbut i need to get the data up until 12:00:00 PM. Can anybody please throw some light on this.Thanks

    Hi,
    fsitja wrote:
    You shouldn't use a mixed syntax. Either you go ANSI on the whole FROM or you can use the Oracle join syntax for every table.Very well put! You CAN mix syntaxes, but it's confusing, and I've never seen an example where plain ANSI syntax doesn't get the right results more clearly.
    OP:
    If you say
    FROM "CUBS SNAPSHOT",client, CancelDesc
       INNER JOIN(...)then the parentheses must contain a sub-query, starting with SELECT (or maybe WITH).
    See [your previous message|http://forums.oracle.com/forums/message.jspa?messageID=3993062#3993062] for what you need to do if you want help.
    As mentioned in that thread, there is no need to group the INNER JOINS. The results will always be the same, regardless of what order the tables are joined.
    You can write the arithmetic expression:
    5 + x + y + 1lots of different ways, including
    5 + (x + (y + 1))
    ((5 + x) + y) + 1
    (5 + x) + (y + 1)
    (5 + x + y) + 1
    5 + (x + y) + 1and it may be a good idea, if it makes your code clearer, so human beings can understand it more easily. But the results will always be the same, no matter how you group the addition operations.
    In the same way, no matter how multiple INNER JOINs are grouped, the results will be the same. I can't think of any situation where clarity would be enhanced by spelling out a join order.

  • Get the firstday and lastday of last month

    Hi,
    How to get the first day and last day of the last month?
    I used this, but it returns Jan 1st 2010
    Firstday:
    select TRUNC(SYSDATE,'year') from dual
    Lastday:
    select LAST_DAY (ADD_MONTHS (SYSDATE,-1)) from dual

    That would be:
    SQL> select TRUNC(ADD_MONTHS (SYSDATE, -12),'yyyy') from dual;
    TRUNC(ADD_MONTHS(SYSDATE,-12),
    01/01/2009
    SQL> Your attempt worked because we're still in january, but starting next month it wouldn't give you the desired output.
    Also if you can avoid using 'year' or 'month' it is advantageous as you're not relying on NLS localization settings that depend on having your database running in english.

  • Last month with data  - BEx variable

    Hi guys,
    I am using in the query the char 0CALMONTH to restrict the KF amount, just to get the last month of data that was loaded in the infocube. I tried with content variables but none of them are working. I used 0CYMONTH or 0CMLMON.
    the only thing that I want is to get from the cube always the last month with data that was loaded.
    Do I need to create a customer exit? does anyone has the code to give me?
    any help¡?
    thank u.
    E.V.

    Hi,
    two alternatives:
    VarExit: perform a select statement on your cube joined with your time dimension; or even directly on your time dimension something like:
    SELECT MAX(SID_0CALMONTH) FROM /BIC/D<cube>T.
    This will give the last CALMONTH with posted data in absolute (not considering your query selection)
    <i>Replacement path variable based on a query: create a query which has to return one record an 0CALMONTH in the columns. Put a TOP1 condition on one of your KeyFig. In your original query restrict 0CALMONTH with a variable of type replacement path on the TOP1 query. The advantage of this alternative is that you can get the last CALMONTH posted with data RELATIVE to your query selections if you move your variables input from the user to the TOP1 query...</i>
    Sorry, the above won't work it out; I just has the same requirement and implemented the varexit reading the time dim table.
    hope this helps....
    Olivier.
    Message was edited by:
            Olivier Cora

  • I bought iMac 27 quad core i7 last June. Last month i have noticed lots of dark patches on the screen and now they are growing more. i bought this from US but now i have moved to Kuwait. How much it cost to replace the screen?

    I bought iMac 27 quad core i7 last June. Last month i have noticed lots of dark patches on the screen and now they are growing more. i bought this from US but now i have moved to Kuwait. How much it cost to replace the screen?

    Mac and Mac models are picky about the RAM the Mac needs to see and use.
    As you have found out, the 1067 speed RAM will not work in your year and model iMac.
    You need the 1333 speed RAM.
    If, you can return the RAM for a refund, do it!
    If not, try online Mac RAM source and seller Crucial memory. They have a table that matches your Mac to the correct and reliable RAM. You may need to contact them to see whether or not they ship to South Africa, though.
    If Crucial dpesn't work out, here's the specs for your year and model iMac that you need to seek out and purchase.
    Maximum Memory
    32 GB (Actual) 16 GB (Apple)
    Memory Slots
    4 - 204-pin PC3-10600 (1333 MHz) DDR3 SO-DIMM
    Good Luck!

  • I am in my last month of my annual Adobe Creative Suite plan and would like to cancel

    I am in my last month of my annual Adobe Creative Suite plan and would like to cancel. How do I do it?

    This is an open forum, not Adobe support... You need Adobe support to cancel a subscription
    -cancel http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • SSRS expression for today,yesterday,Lastweek ,Last fortnight,Last Month, Year to date

    Hi All;
    I have a field called createdon 
    Using this field i need to create the SSRS expression for the table as below 
    Any help much appreciated
    Thanks
    Pradnya07

    use expressions as below
    assuming this is to be done in SSRS
    Today
    =COUNT(IIF(
    DateDiff(DateInterval.Day,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Day,Cdate("01/01/1900"),Now()),Fields!YourRequiredField.Value,Nothing))
    Yesterday
    =COUNT(IIF(
    DateDiff(DateInterval.Day,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Day,Cdate("01/01/1900"),Now())-1,Fields!YourRequiredField.Value,Nothing))
    LastWeek
    =COUNT(IIF(
    DateDiff(DateInterval.Week,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Week,Cdate("01/01/1900"),Now())-1,Fields!YourRequiredField.Value,Nothing))
    Last fortnight
    =COUNT(IIF(
    (DateDiff(DateInterval.Week,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Week,Cdate("01/01/1900"),Now())-1)
    Or (DateDiff(DateInterval.Week,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Week,Cdate("01/01/1900"),Now())-2),Fields!YourRequiredField.Value,Nothing))
    Last Month
    =COUNT(IIF(DateDiff(DateInterval.Month,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Month,Cdate("01/01/1900"),Now())-1,Fields!YourRequiredField.Value,Nothing))
    Year To Date
    =COUNT(IIF(DateDiff(DateInterval.Year,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Year,Cdate("01/01/1900"),Now())
    And
    DateDiff(DateInterval.Day,Cdate("01/01/1900"),Fields!createdon.Value) <= DateDiff(DateInterval.Day,Cdate("01/01/1900"),Now()),Fields!YourRequiredField.Value,Nothing))
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • My phone has been smashed I need to get records of all my iMessages and texts from the last month. How do I get these?

    My phone has been smashed I need to get records of all my iMessages and texts from the last month. How do I get these?

    Do you have a backup of your iPhone which contains these messages?
    If so, you can restore a new iPhone from that backup during setup.
    If not, the messages are gone.

Maybe you are looking for

  • How can I take an old Apple ID off iPad?

    I have my moms iPad now ( I do believe that it is the 2 Gen). I have replaced the old Apple ID with the new one. The only problem now is that I am going to test out the iCloud and it keeps bringing the old ID up. It will not let me click it to change

  • Need help with adding a Key flex field to a seeded OAF page

    We have a seeded OAF page on which we already have Account Key Flex Field. Properties of this flex field are: The ApplShortName - SQLGL Name - GL# Type - Key As per the client requirement, in the KFF screen, we have disabled the seeded structure for

  • Can't get personal signature to work in latest version of Yahoo for ipad

    I was able to add personal signatures to all my email accounts hot mail, gmail & in the previous verisons of yahoo for iPad. After updating to the latest of yahoo, I cannot remove the generec "sent form my ipad"  & use a peronal sig. Any thoughts? I

  • How to arm channel 1 of a PCI 6133 DAQ card using labview?

    Hi, I am new to the Labview and I need some help.  I have a PCI 6133 multifunction DAQ card and I'm using Labview 8.2 to capture five channels waveform data.  I setup channel ai0 to be the trigger channel and I need to capture data from ai0, ai1, ai2

  • Apache2 config issue with CFMX8 on Ubuntu

    hi there - I have a new Ubuntu laptop I purchased from Zareason, (great deal, nice people). They were cool to install CFMX8 developer version on my laptop before shipping. My issue is this: The cfadmin works fine, so I know CF is at least up and runn