12 trailing months in MDX
Hi,
I've been trying to write a formula on a member of a SCENARIO dimension in an ASO database to calculate the last 12 trailing months of another member of SCENARIO. It's pretty easy when you have a unique dimension for both periods and years (thanks to the .Lag function), but I have two distinct dimensions - one for years and one for periods - in this database and haven't succeeded to write a correct formula yet.
Basically what I need is TTMscenario = SUM(Last 12 months->"Actual scenario") in MDX
Thanks a lot for your help,
JM
Use Tuplerange, it should work just like @Xrange in BSO.
Similar Messages
-
CURRENT YEAR PREVIOUS TWO MONTHS SALES+MDX
QUERY TO GET CURRENT YEAR LAST TWO MONTH SALES DYNAMICALLY IN MDX
assuming you are looking for data with the latest two months and taking adventure works DW 2008 as sample DB
try this
select [Measures].[Internet Sales Amount]
on 0,
{Tail(nonempty(descendants([Date].[Calendar].[Calendar
Year],[Date].[Month of Year]))).item(0),
Tail(nonempty(descendants([Date].[Calendar].[Calendar
Year],[Date].[Month of Year]))).item(0).prevmember}
on 1
from [Adventure Works] -
Trailing 12 months in Essbase 11.1.2.2 ASO cube
I have an outline with the first four dimensions being ReportingPeriod, Years, TimeView, Accounts -
ReportingPeriod
-Qtr1
--Jan
--Feb
--Dec
Years
-Y2012
-Y2011
-Y2004
TimeView
-Monthly
-YTD
-Trailing12Months
Accounts
-Revenue
I easily got YTD working correctly with regular and time-balance accounts with the following MDX -
AGGREGATE(PeriodsToDate([ReportingPeriod].Generations(2),ReportingPeriod.CurrentMember),[Monthly])
But whatever MDX I try to implement Trailing12Months, I don't seem to be able to make any headway. Any ideas? Thank you!
Edited by: user10655152 on Aug 15, 2012 3:34 PM
Edited by: user10655152 on Aug 15, 2012 3:35 PM
Edited by: user10655152 on Aug 15, 2012 3:35 PM
Edited by: user10655152 on Aug 15, 2012 3:36 PMThank you Dan. I had already successfully implemented the general idea suggested by Glenn. However, the problem there, as expected, was in the handling of TBLast accounts. The MDX below finally seems to give me trailing-12 months which also works correctly with TBLast accounts and the Qtr roll ups, although I'm not sure if this is the most efficient MDX possible for what I'm trying to achieve -
===Start MDX formula for member T12 of the outline earlier in the thread====
AGGREGATE(
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-11)),
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-10)),
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-9)),
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-8)),
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-7)),
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-6)),
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-5)),
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-4)),
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-3)),
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-2)),
([Years].CurrentMember.NextMember,[ReportingPeriod].CurrentMember.Lag(-1)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(11)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(10)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(9)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(8)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(7)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(6)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(5)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(4)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(3)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(2)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember.Lag(1)),
([Years].CurrentMember,[ReportingPeriod].CurrentMember)
, [Monthly])
===End MDX=====
Only 12 of the 23 lines above will return non-empty results, so this works for me. Also, CurrentMember (without any Lag) needed to be listed last, so the TBLast accounts would show up correctly. I suppose this would still not work if my accounts dimension had a mix of TBLast and TBFirst/Avg members, but since I only have TBLast, I am fine for now. Thank you Glenn, your initial idea really helped an ASO newbie in need of direction! -
MDX to fetch record from 1st of current month to 5th of next month and same for previous year
In my date dimension I have a attribute CalendarDate. I do have a hierarchy [Date].[Year].[Quarter].[Month].[CalendarDate] as well. I need to fetch data starting from 1st working day of current month to 5th working day of next month by MDX. I do have a attribute
to filter working day as IsWorkingDay. How can we get a dynamic MDX that will find the current month first and than it will filter the record from 1st working day of current month to 5th working day of next month. And same for the previous year same month
to compare.
Thanks in advance!
PalashHi P,
You can use a calculated member to dynamically add all the days in the current month and the first 5 in the following month. You will need to change measure, cube and hierarchy names.
with member measures.ThisMonthAnd5 as
sum([Date].[Year].parent.children,Measures.[Sales])
+sum(Head([Date].[Year].parent.nextmember.children,5),Measures.[Sales])
select
{Measures.[Sales]
,Measures.ThisMonthAnd5
} on 0,
non empty [Date].[Year].[CalendarDate]
on 1
from MyCube
Richard -
Error "Members, tuples or sets must use the same hierarchies in the function" in MDX
the following MDX returns error: "Members, tuples or sets must use the same hierarchies in the function"
WITH
MEMBER [Measures].[Prev Year] AS
[Measures].[returns],
PARALLELPERIOD
[Exec Date].[Year].Levels('Year'),
1,
[Exec Date].[Year].CURRENTMEMBER
MEMBER [Measures].[Prev Month] AS
[Measures].[returns],
PARALLELPERIOD
[Exec Date].[Month Num].Levels('Month Num'),
1,
[Exec Date].[Month Num].CURRENTMEMBER
MEMBER [Measures].[Prev Day] AS
[Measures].[returns],
PARALLELPERIOD
[Exec Date].[Day].Levels('Day'),
1,
[Exec Date].[Day].CURRENTMEMBER
SELECT NON EMPTY { StrToMember("@ExecDateLevel"), [Measures].[returns] } ON COLUMNS, NON EMPTY { ([Employees].[Company].[Company].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM (
SELECT (
STRTOSET(@ExecDateHierarchy, CONSTRAINED)
) ON COLUMNS FROM [cbSales]) WHERE ( IIF( STRTOSET(@ExecDateHierarchy, CONSTRAINED).Count = 1, STRTOSET(@ExecDateHierarchy, CONSTRAINED), [Exec Date].[Hierarchy].currentmember ) ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
and when I replace "StrToMember(@ExecDateLevel)" with
StrToMember("[Measures].[Prev Month]") the MDX is compiled correctly.
what is the problem?
How can I solve that?Hi Breceive,
In your scenario, the issue is caused by that you select dimension members and measures on the same axis without a crossjoin.
SELECT NON EMPTY { StrToMember("@ExecDateLevel"), [Measures].[returns] } ON COLUMNS
To avoid this issue, you can use the query below.
WITH
MEMBER [Measures].[Prev Year] AS
[Measures].[returns],
PARALLELPERIOD
[Exec Date].[Year].Levels('Year'),
1,
[Exec Date].[Year].CURRENTMEMBER
MEMBER [Measures].[Prev Month] AS
[Measures].[returns],
PARALLELPERIOD
[Exec Date].[Month Num].Levels('Month Num'),
1,
[Exec Date].[Month Num].CURRENTMEMBER
MEMBER [Measures].[Prev Day] AS
[Measures].[returns],
PARALLELPERIOD
[Exec Date].[Day].Levels('Day'),
1,
[Exec Date].[Day].CURRENTMEMBER
SELECT NON EMPTY { StrToMember("@ExecDateLevel")*[Measures].[returns] } ON COLUMNS, NON EMPTY { ([Employees].[Company].[Company].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM (
SELECT (
STRTOSET(@ExecDateHierarchy, CONSTRAINED)
) ON COLUMNS FROM [cbSales]) WHERE ( IIF( STRTOSET(@ExecDateHierarchy, CONSTRAINED).Count = 1, STRTOSET(@ExecDateHierarchy, CONSTRAINED), [Exec Date].[Hierarchy].currentmember ) ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
Here is a similar thread for you reference.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/3c21d9a8-640d-4dde-bc76-08d1fcbb3a31/multiple-dimension-query?forum=sqlanalysisservices
Regards,
Charlie Liao
TechNet Community Support -
[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,
GuillaumeHello 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 -
All forms of payment are declined since 5.1 update
I've had nothing but problems since updating to 5.1; verify payment message keeps popping up (although that seems to have stopped in the last day or so), Hulu Plus only working over WiFi (thankfully it was just a trail month, already canceled the service because my WiFi is not reliable enough for HD streaming) and now this new issue that is preventing me from renting/buying any movies or TV shows.
When ever I try and purchase a movie or TV show it says my credit card has been declined. Problem is, I can still purchase apps, songs, movies and shows from my iPad, iPhone and PC. I only get the declined message on my Apple TV. I've tried 2 different credit cards and get the same declined message on my ATV, but the both work on every other device I have. I've even tried setting up Paypal; again using Paypal works on all my devices except the ATV, only the message is different when using Paypal. Instead of saying it is declined the message says that the "iTunes Store is unable to complete purchases at this time."
I don't know what to do, I've tried restarting, restoring, signing in/out, 3 different forms of payment and nothing works; I can't make purchases from my ATV. This all started with the last update, I've never had an update from Apple screw up a device this much. The only thing I haven't tried is throwing it through a window but, I'm pretty sure that will not fix the problem.
Please, does anyone have any idea of something else I can try? I know I can just purchase the movies or shows on my phone, iPad or PC but, that defeats the whole purpose of being able to do it through the Apple TV. I wish I could revert back to 5.0.2, had no issues except for the occasional sudden reboot before 5.1.I just noticed the same problem on my Apple TV...never had this problem bf but now I've seen this I realize it started after the update here too....Apple seems to be more of a hassle these days than not....I thought updates were supposed to fix problems not create them but it seems most updates the past year only create issues...sorry I don't have an answer for you and I'm just as annoyed...it's an expensive product to not be able to use for what I use it for mostly...Get off your rear apple and start making our lives easier or I'll go another route when buying products bc I can't deal with these constant issues
-
After overcoming the stuff in "rookie needs help", I now have the entire site ready to go. I'm under an agreement not to show the content publicly until my client approves it, so apologies for not posting a link.
FWIW, this is a project directly related to the paperless electonic voting controversy, and the upcoming election (which we all anticipate to be an immense crisis - they should have solved this paper trail **** months ago), so all help is appreciated by more than just me - this one's for all of us. The site is likely to become a high-profile destination as November approaches.
I need to read a newsfeed from another related site. However, the ability to install code on the site I'm presently building is limited to what I can put into the immediate web. The site is hosted on an ASP (application service provider), and I'm uncertain what the sysadmin will welcome beyond that.
I have an ASP script that reads the newsfeed. It is demonstrated here:
http://www.gbdg.net/clay/index_vu.asp
What I am looking for, if such exists, is a similar JSP script. I am hoping this is simply a page I can install in my new site, and then execute via an include.
Could someone please direct me to such a script, assuming this is possible? Or point me in the right direction?
Thanks,
GregYikes!
I have a week before a mandatory launch, and this is one small aspect of what I need to do. I pray somone knows a script or such that I can download and install - the last thing I hope to do this week is to learn how to build a custom tag.
Just as this page http://www.gbdg.net/clay/index_vu.asp reads content from http://www.votersunite.org/news-rss/index.xml and displays it in a formatted table, I can just as easily cause that box of news items to appear on the home page of a site - that page would also have other content. What I am looking for is a script that reads the XML newsfeed and displays it on a web page.
Thanks
FYI, here is the ASP RSS newsreader script that causes the above page to work:
<%
Dim objXML
Dim objXSL
Dim objFSO
Dim strFile
Dim strFileName
Dim strXSL
Dim strURL
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
' File extension
strFileName = "voters.xml"
' Format of current file e.g. 200160710cnn.xml
strFile = Year(Now) & Month(now) & Day(now) & Hour(now) & strFileName
' Style sheet
strXSL = "/includes/rss/rss.xsl"
' URL for XML Feed
strURL = "http://www.votersunite.org/news-rss/index.xml"
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' If a current file for this hour doesn't exist, then get a new one.
If Not (objFSO.FileExists(Server.MapPath(strFile))) Then
Set objXML = Server.CreateObject ("MSXML2.ServerXMLHTTP.4.0")
objXML.Open "GET", strURL, False
objXML.Send
xmlGet = objXML.responseText
'strip out the crap to make it work...otherwise you will get a "The data necessary to complete this operation is not yet available." error.
xmlGet = replace(xmlGet,"<!DOCTYPE rss PUBLIC ""-//Netscape Communications//DTD RSS 0.91//EN"" ""http://www.scripting.com/dtd/rss-0_91.dtd"">","")
' Create new cnn XML file
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(Server.MapPath(strFile), ForWriting, True)
f.Write xmlGet
f.Close
Set objXML = Nothing
' Now delete any older cnn files
Set objFolder = objFSO.GetFolder(Server.MapPath("./"))
For Each objFile in objFolder.Files
If (objFile.Name = strFile) or Instr(objFile, strFileName)=0 then
Else
objFSO.DeleteFile(Server.MapPath(objFile.Name))
End If
Next
End If
Set objFSO = nothing
' Now load XML and XSL documents
Set objXML = server.createobject("MSXML2.DOMDocument.4.0")
Set objXSL = server.createobject("MSXML2.DOMDocument.4.0")
objXML.load(Server.MapPath(strFile))
objXSL.load(Server.MapPath(strXSL))
Response.Write objXML.transformNode(objXSL)
Set objXML = Nothing
Set objXSL = Nothing
%>
RSS.xsl:
<?xml version="1.0" ?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:template match="/">
- <xsl:for-each select="rss/channel/item">
- <xsl:if test="position() < 8">
- <a>
- <xsl:attribute name="href">
<xsl:value-of select="link" />
</xsl:attribute>
<xsl:value-of select="title" />
</a>
- <xsl:if test="pubdate!=/">
<xsl:value-of select="pubdate" />
</xsl:if>
<img src="/images/spacer.gif" alt="" width="10" height="6" border="0" />
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet> -
After effects cs4 won't install with the Adobe Creative Suite 4
yesterday I bought Adobe Creative Suite 4 Production Premium, i let it download through out the night and the next day i installed it and noticed that it came every single application except after effects cs4. there is no folder or icon for it, but everything else works. im in the process of uninstalling it and re-installing it, but i doubt it will help. i downloaded the after effects cs4 trail months ago, then deleted it. i don't think that's the problem though.I called adobe and was on hold for literally two hours, and when i was able to talk to someone they were not really able to help much.
im on a macbook, version 10.5.8
2.4 GHz intel core 2 duo
2 gb 667 MHz DDR2 SDRAM
EDIT: i installed it again, looked at the install options more closely and realesed that it does come with it, it just wont let me install it or check it to be installed, because it says its already installed. i checked all over my hard drive for it and its not there. i really need some help.
any help would be appreciated, thanks.
also if I waited and got after effects cs5 do you think it would actually work, and would i be able to get the student discount again?We cannot know. We need exact system info. As a start, you might consider turning off UAC completely and running as admin...
Mylenium -
I need to calculate a Member for FY2012 as follows:
FIX("Feb")
"Member1" = "Member2" -> "Jan" + "Member2" -> "Dec" -> "FY11" + "Member2" -> "Nov" -> "FY11" + "Member2" -> "Oct" -> "FY11" + "Member2" ->"Sep" -> "FY11"
ENDFIX
FIX("Mar")
"Member1" = "Member2" -> "Feb" + "Member2" -> "Jan" + "Member2" -> "Dec" -> "FY11" + "Member2" -> "Nov" -> "FY11" + "Member2" -> "Oct" -> "FY11"
ENDFIX
..and so forth.
this is a simplified formula but basically i want the formula to go back to previous year as well. using @PRIOR but the rangelist can be either period or Year, while in @MDSHIFT it can be in both current year and previous year.. is there a way I can achieve or have to write these detailed formulas by fixing on each month.
Thank You for your helpHi,
So basically you just want to calculate the last 5 trailing months ?
To do this I use a variable to calculate the index of the current Period. Then I use a @SUMRANGE and I defined my starting and ending period based on the index of the current period using @HspNthMbr. -
I have used the following script to return measures for the last 7 days:
LastPeriods(7,
StrToMember
"[Date].[Year Week Day].[Date].&[" + FORMAT(Now(),"yyyy-MM-ddT00:00:00")
+"]"
This is fine for measures that are recorded every day but I also have measures that are recorded every few weeks.
I therefore need a script to return the last 7 readings (for example). I can use the following filter to return all measures and all dates for each Well. How can I modify to return only the last 7 measurements?
SELECT
NON EMPTY
[Measures].[CH4 Field]
ON COLUMNS,
NON EMPTY
Filter
{[Well].[Well].[Well Key] *
[Date].[Year Month Day].[Date].MEMBERS},
NOT ISEMPTY([Measures].[CH4 Field])
ON ROWS
FROMDarren, I am testing this. My experimental Calendar has the following levels:
[Year]
[Quarter]
[Month]
[Week Month]
[Date]
MDX:
SELECT LastPeriods(7, [All Calendar Pyramid].[2010].[Q1 2010].[February 2010].[Week 2 February 2010]) ON COLUMNS
FROM [Incidence of Diseases]
Results:
Week 1 January 2010 Week 2 January 2010
Week 3 January 2010 Week 4 January 2010
Week 5 January 2010 Week 1 February 2010
Week 2 February 2010
6,633.00 6,760.00
5,657.00 6,630.00
3,564.00 7,183.00
7,580.00
+__+ -
I have a situation, where i need to write expression Period to date(PTD). i want to know how to get the period date. i want you to help in writing Period date or else is there any function to get period date for a given date(the date is given
from the parameter dynamically) in MDX for SSRS report
ramHi ram,
Per my understanding that you want to get the period date based on the month selected and the given date, right?
Could you please provide details information below to help us better understanding your requirements, thus we will be more effective to provide an solution:
What is the format of the period date you want to get, is this date in the DB and you want to filter it based on the month and the given Date?
Did the month and given date are two parameters in the report? if possible, could you please provide some sample data in the DB and also the snapshot of the report structure
I assume you want to get the period date(mm/dd/yyy) between the select month(e.g:Feb) and the given date (10/1/2014) and you should get the date between(02/01/2014-10/1/2014).
If so,and you also have two parameter "Month","EndDate"(EndDate is the given date), please reference to details information below:
You can create an new parameter "BeginDate" (Date/Time) which is the begin date of the period, you can use the expression to get the value based on the value of the month and the year value from the given date,finally hide this parameter:
Specify the available value:
Label:=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value)
Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
Specify the default Value:
Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
Add filter to the dataset as below:
Preview you will get all the date in the given Period:
If you still have any problem, please feel free to ask.
Regards
Vicky Liu -
MDX to dynamically create period to date for each month of current year
I need some help with MDX. I am not even sure if this is possible to do but here is what I need. Any help is greatly appreciated.
I have a Date dimension with a hierarchy defined as Year-Qtr-Month-Date
I have a measure called Rentals
Assume the current date is 10/24/2014. I want to display by month for the year 2014, the sum of rentals equivalent to the current MTD. So January would sum 1/1 thru 1/24. February would sum 2/1 thru 2/24. March would sum 3/1 thru
3/24, etc.
On the end of the current month, all months would display the sum of the whole month. I am not concerned if a month ends on the 30th or 31st. The end is end.
It needs to be dynamic enough so that if the current date is the 27th, each month would sum from the 1st to the 27th.Hi Rocko,
According to your description, you want to compare the sum amount of rentals for each month, right?
In MDX, we can use
PARALLELPERIOD function returns a member from a prior period in the same relative position as a specified member. So you can use the query like
with set Period as {[Arrival Date].[Date].[Month].&[2014]&[1]:[Arrival Date].[Date].[Month].&[2014]&[27]}
member [Arrival Date].[Date].[0] as sum({Period})
member [Total Amount N-1] as (PARALLELPERIOD([Arrival Date].[Date].[Month], 1, [Arrival Date].[Date].[Year].&[11]), [Measures].[Total Amount])
Here is a sample query on AdventureWorks cube.
SELECT ParallelPeriod ([Date].[Calendar].[Calendar Semester]
, 3
, [Date].[Calendar].[Month].[October 2003])
ON 0
FROM [Adventure Works]
Regads,
Charlie Liao
TechNet Community Support -
MDX for Start of Month Values at Daily level
Hey Guys,
I am dealing with a requirement as below, the solution i have is either not addressing the complete problem or is extremely slow and in many cases just not feasible. Need a little help on the same.
Problem: Need a query with cross join of 4 dimension (10 levels) and a date dimension, i need to determine a measures's first
available value across time periods such as Start of month, start of year Etc..
I have
dimA - Level A1
dimB - Leve B1,B2,B3
dimC - Level C1
dimD - LevelD1, D2,D3,D4,D5
Date Dimension - Date, Month, Year as levels.
Measure - M1 To M5
Query:
SELECT
NON EMPTY
[Measures].[M1]
,[Measures].[M2]
,[Measures].[M3]
,[Measures].[M4]
,[Measures].[M5]
,[Measures].[M1SOM]
} ON COLUMNS
,NON EMPTY
[DimA].[A1].[A1].ALLMEMBERS*
[DIMB].[B1].[B1].ALLMEMBERS*
[DIMB].[B2].[B2].ALLMEMBERS*
[DIMB].[B3].[B3].ALLMEMBERS*
[DIMB].[B4].[B4].ALLMEMBERS*
[DIMB].[B5].[B5].ALLMEMBERS*
[DIMC].[C1].[C1].ALLMEMBERS*
[DIMD].[D1].[D1].ALLMEMBERS*
[DIMD].[D2].[D2].ALLMEMBERS*
[DIMD].[D3].[D3].ALLMEMBERS*
[Date].[Date].[Date].ALLMEMBERS*
[Date].[Month].[Month].ALLMEMBERS*
} ON ROWS
FROM
[Cube]
***The above query has all those cross joins as this query would power an SSRS report dataset.
Need to create a new calculated measure or a real (persisted measure) that displays the Start of month & Start of year Values. Below are the options i have currently. Lets assume, Measure M1 is the one for which i need the SOM and SOY values.
Create a persisted measure (M1SOM) based off the measure M1 and provide an aggregation function of "FirstNonEmpty" : This works perfectly when we run a query at Month level i.e. in the above query have [Date].[Month].[Month].Allmembers instead
of [Date].[Date].[Date].Allmembers. It displays the first available non empty value of the month. However, this means the rest of the measures are aggregated at month level. If i want to display the daily values of the other measures along with SOM values
for this measure it wont work, cause the scope now changes to a single date and i just get the daily value in the M1SOM measure as well.
Create a calculated measure (M1SOM) as below, along with the query above and the same thing happens. Cant display the SOM values at a daily date level.
WITH
MEMBER [Measures].[M1SOM] AS
[Date].[Date].FirstChild
,[Measures].[M1]
3. Create a calculated member as below, This works! however, the query
absolutely kills my machine and takes forever to execute, if i run it with more than 3 levels in the cross join.
WITH MEMBER M1SOM AS Head(NonEmpty({[Date].[Date].Parent.Children}*[Measures].[M1SOM])).Item(0)
Is there a better way to achieve the SOM and SOY calculations at a daily level?
Thanks
SrikanthHi Srikanth,
Basically you want to get the cell values on different granularity for date dimension in the same result set. For performance consideration, we suggest to use MDX to get the 2 types of value separatedly and merge with T-SQL.
Below is an example on how to get data from MDX within T-SQL for your reference.
SET
@mdx
=
'{some
dynamic MDX}'
SET @sql
=
'SELECT a.* FROM
OpenQuery(LinkedAnalysisServer, '''
+
@mdx
+
AS a'
BEGIN TRY
INSERT INTO #result
EXEC sp_executesql @sql
END TRY
BEGIN CATCH
IF ERROR_NUMBER <>
'The error number you are seeing'
BEGIN
RAISERROR('Something happened that was not an empty result set')
END
END CATCH
SELECT * FROM
#result
Regards -
How to get month value from custom calendar without passing parameter from SSRS in MDX query
Could you please throw some light to achieve below requirement?
I need to filter the data between two periods dynamically . The date calendar here works differently(ex:-Date 26-Aug-2014 will fall in period 7 which is last date and 27-Aug-2014 will fall in period 8 and it is first date of period 8),so I cannot go
with system date period/Month. Date Hierarchy is like YEAR,QUARTER,PERIOD ,WEEK and DAY.
I cannot use SSRS for passing parameter. Requirement is to extract last 2 period of data dynamically in Power Pivot with MDX.
Thanks ChandanHi Chandan,
You might try something like this
Tail(null:
Extract(
StrToMember("[FYDay].[DATE].&[ + cStr(Format(Now(),"yyyy-MM-ddT00:00:00")) + "]")
*[FYDay].[DateHierarchy].[Day]
,[FYDay].[DateHierarchy]).parent.parent
,2)
What it is doing is multiplying Day by the current date, which returns a set of one date with cardinality of (Date,Day). The Extract is pulling out just the datehierarchy Day. the the Tail() is getting it and the previous day.
Hope that helps,
Richard
Maybe you are looking for
-
I have two Macbooks, early model (2006) and later model (2007). I've set the display to go to sleep while on Power Adapter on each model using Energy Saver preferences. It's not happening on my 2007 model - never goes to sleep no matter how long I se
-
Adding query string to files already within shared documents
Am a Sharepoint newbie, so hopefully this is an easy one. Am trying to add a query string to some hyperlinks (of PDF files) that are already published in a Shared Documents web part. What's the best way to accomplish this? Can't seem to find an easy
-
Why doesnt itunes pull up the song i search when i click on it
I HATE the new itunes, its uneccisarily complicated. Everything on itunes is, everytime i search a song in the search box it pops up in a list under the search box but when i push it, it doesnt pull it up in my library... annoying. Why wont it pull u
-
hi friends i am sending the structre of two tables in my data base. 1. Gl_Insert Code_No varchar2(5) Cash_Adj Char(1) Particulars varchar2(100) Credit_sum number Debit_sum number Scroll_No number 2. USERS User_id number U_name varchar2(20) log_status
-
Naming, arranging linked photos with Excel document info
Hello! I am attempting to make a newspaper layout consisting for graduates from our local high schools. I have been provided a disc with literally hundreds of pictures. The photos in the layout need to be arranged in alphabetical order, but the file