Solved

Find last month with data

Posted on 2010-09-03
11
922 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
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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

820 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