?
Solved

Find last month with data

Posted on 2010-09-03
11
Medium Priority
?
938 Views
Last Modified: 2016-02-15
I am trying to create an MDX query that will return the last month with data from the cube.  The problem is that there are zeroes loaded into the months where there is no data.  I have attached the query I am trying to use but it always returns the last month of the year and shows 0 as the measure.
SELECT { parallelperiod([Fiscal Year FMP].[Fiscal Year].[FY],1,closingperiod([Fiscal Year FMP].[Fiscal Year].[Mth], [Fiscal Year FMP].[Fiscal Year].defaultmember)),closingperiod([Fiscal Year FMP].[Fiscal Year].[Mth], [Fiscal Year FMP].[Fiscal Year].defaultmember) } ON COLUMNS ,

{ DESCENDANTS( [FMP_Facility].[FMP_Facility].[Level ID].&[STATION].&[V20], [FMP_Facility].[FMP_Facility].[Division] ) } ON ROWS  

FROM [FMP] 

WHERE ( [Category].[Category].[Cat Desc].&[112 ARS NONCUM COLLECTIONS/CUM COLLECTIONS], [Measures].[Numerator] )
CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL

Open in new window

0
Comment
Question by:vincem1099
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 7

Expert Comment

by:d507201
ID: 33601360
Wow, good stuff.  I've gotta learn something about MDX queries.
0
 
LVL 7

Author Comment

by:vincem1099
ID: 33619972
It would be better stuff if I could figure out how to determine the last month without a 0 loaded into the data.
0
 
LVL 9

Expert Comment

by:radcaesar
ID: 33631048
0
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 
LVL 7

Author Comment

by:vincem1099
ID: 33631216
That solution is for a 12 month period not for the last period with data
0
 
LVL 11

Expert Comment

by:theartfuldazzler
ID: 33637151
0
 
LVL 7

Author Comment

by:vincem1099
ID: 33663532
That will find the maximum amount but not the last period without 0 for data
0
 
LVL 11

Expert Comment

by:theartfuldazzler
ID: 33681115
Under SQL I would try something like:

SELECT MAX(Case when Var ne 0 then Month else 0 end) as Last_Month

Not sure if the same will work for MDX.
0
 
LVL 7

Author Comment

by:vincem1099
ID: 33717561
I think a filter function needs to be used but I am having trouble with the syntax.  This code gives me the error that  a level expression is expected but  a tuple was used:
SELECT { parallelperiod([Fiscal Year FMP].[Fiscal Year].[FY],1,closingperiod(filter([Fiscal Year FMP].[Fiscal Year].[Mth],[Measures].[numerator]<>0), [Fiscal Year FMP].[Fiscal Year].defaultmember)),closingperiod([Fiscal Year FMP].[Fiscal Year].[Mth], [Fiscal Year FMP].[Fiscal Year].defaultmember) } ON COLUMNS ,

{ DESCENDANTS( [FMP_Facility].[FMP_Facility].[Level ID].&[STATION].&[V20], [FMP_Facility].[FMP_Facility].[Division] ) } ON ROWS  

FROM [FMP] 

WHERE ( [Category].[Category].[Cat Desc].&[112 ARS NONCUM COLLECTIONS/CUM COLLECTIONS], [Measures].[numerator] )
CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL

Open in new window

0
 
LVL 7

Accepted Solution

by:
vincem1099 earned 0 total points
ID: 34537096
Apparently the data cube was updated while this question was open so that the default member for the month hierachy was adjusted to the current month so this MDX query returns the current month with data without having to address the original problem:
 
SELECT { [Fiscal Year FMP].[Mth].defaultmember } ON COLUMNS ,

{ DESCENDANTS( [FMP_Facility].[FMP_Facility].[Level ID].&[STATION].&[V20], [FMP_Facility].[FMP_Facility].[Division] ) } ON ROWS  

FROM [FMP] 

WHERE ( [Category].[Category].[Cat Desc].&[112 ARS NONCUM COLLECTIONS/CUM COLLECTIONS],[Measures].[numerator] )
CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL

Open in new window

0
 
LVL 7

Author Closing Comment

by:vincem1099
ID: 34618301
Problem resolved by Cube Data changing.  Original problem never really resolved.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question