Solved

Find last month with data

Posted on 2010-09-03
11
924 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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

688 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