I'm trying to achieve the following: I have a measure: [Measures].[Sales] and a time dimmension: [Time].[Year - Month - Day]. I would like to add new measure: [Measures].[Sales SPLY] to work in the following way:
MONTH-----------------Sales--------------Sales SPLY
2009 January--------120 000,00--------110 000,00
2009 February ------100 000,00--------90 000,00
2009 March----------120 000,00--------110 000,00
TOTAL:---------------340 000,00--------290 000,00
The value of [Sales SPLY] is calculates using the following way: I created a new Sum measure, and in a Cube Script I replace it with the following code:
([Measures].[Sales SPLY], Leaves([Time])) = (PARALLELPERIOD([Time].[Year - Month - Day].[Year],1,[Time].[Year - Month - Day].currentmember), [MEASURES].[Sales])
It's working, however is just very, very slow. Does anyone know a better way of writing this MDX? using only the parrarel period in a calculated member will result in a bad value of the Total in SPLY measure. Please, I googled a lot and couldn't find any thing better than this.
I tend to just create a member like
WITH
MEMBER [Measures].[Sales SPLY] as ([Measures].[Sales], ParallelPeriod([Time].[Year - Month - Day].[Year],1,[Time].[Year - Month - Day].currentmember))
SELECT {[Measures].[Sales], [Measures].[Sales SPLY]} ON 0, ....
And it works fine.
How are you using it in your query overall?
Rob
Related
I have an earnings table in my Google Data Studio report from January 21 - YTD.
But what i want is a table that shows me YTM (so this year until last month) Jan-21 til Sep-21 and that dynamicly on 1st Nov, Okt-21 is added to the table, and on 1st dec Nov-21
is added etc.
Because the Total YTD value is other wise too high, due to cost being booked at the end of the month and earnings through the month.
Filters wont let you do it dynamicly,
date range filters same,
always possible to do it manualy with date range but this i cannot ask from my client.
any suggestions??
Kind regards
I found the answer,
i left the question for when someone else wants to do it,
it is actualy simpel fixed by using advanced date filter and then leaving the start date on 1-jan, and end date to today minus 1 month.
this gave me the exact result i needed yt last month
I am using a pivot table on Google Data Studio, which shows total income for each month of the year.
I wish to show total income for each month of the year, separated by years - for example, January 2017, and January 2018 will hopefully appear one above the other.
I attached an example that describes best what I need (couldn't find an explanation for how its built in the picture)
In the picture, the equivalent for "Years" is "Gender"
Figured it out. its just by adding another metric in the row dimension, missed it on the first try..
I have a cube with two measures, say Measure A and Measure B. I need to create a single measure say C, from these two based on the business rule at any level of the hierarchy,
If A is not empty at the current level (has value for all children at that level), then just aggregate A. Else, aggregate A wherever it is present and aggregate B wherever A is not present and then sum both to make C.
It goes like this
Quarter Month A B
Q1 Apr 2 3
Q1 May 4
Q1 Jun 4
C should be 10 at Quarter level. Also, 2 for Apr, 4 for May and 4 for Jun [Month level]
I used the following MDX which works fine at Month level.
IIF(IsEmpty([Measures].[A]), [Measures].[B], [Measures].[A])
But, at quarter level it just gives me 2 instead of 10 which I now know why :)
Any pointers on building a MDX to make it work at any level
[Year - Semester - Quarter - Month] (Granularity is at Month level only)
will be helpful. Thanks :)
You can use this Mdx
Sum(
Descendants('current member on your time hierarchy', 'month level'),
CoalesceEmpty([Measures].[A], [Measures].[B])
)
CoalesceEmpty([Measures].[A], [Measures].[B]) is equivalent to IIf(IsEmpty([Measures].[A]), [Measures].[B], [Measures].[A])
I have the following payroll table in an SSRS 2008 (R2) report:
The dataset returns labor transactions consisting of the following fields:
STARTDATE
STARTTIME
FINISHDATE
FINISHTIME
REGULARHRS (difference between finish and start)
REFWO (such as "Travel", "Holiday", "Work", etc and is used to sort into the categories shown in the table above)
TIMEWORKED (0/1 flag that indicates whether or not it counts towards "Time Worked" category)
I have a column grouped on STARTDATE so that it displays each day of the week (our weeks go Mon through Sun). Everything down to "Unpaid Time Off" is a simple expression (usually just in the format Sum(IIF(something,A,B)) in both the daily column and the weekly (Totals) column. In the "Interim Regular" box (for the day grouping), I have the following expression:
=IIF(Weekday(Fields!startdate.Value)=1
OR Weekday(Fields!startdate.Value)=7
OR ReportItems!Holiday.Value>0,
0,
ReportItems!TimeWorked.Value-ReportItems!Holiday.Value-ReportItems!Bereave.Value)
Basically what I'm doing is saying: If STARTDATE is a Saturday, Sunday, or Holiday, the regular hours would be 0 since it would fall into OT1.5 (overtime, time and a half), otherwise I calculate the regular hours worked by subtracting Holiday time and Bereavement time from the Time Worked (since both are included as part of Time Worked). This part works great!! But when I try to sum up the total for the week using =Sum(ReportItems!InterimRegularDaily.Value) it tells me that I can't use an aggregate on a report item and that aggregate functions can be used only on report items contained in page headers and footers. I've done extensive googling to see if there is a solution, but everything seems to involve writing custom functions. I can't believe it would be THAT hard to simply sum up a group calculation in an outer group!
Any and all help would be greatly appreciated!!
Thanks!
You can add the scope the your Sum() expression to reverence the the whole dataset or a group:
'Returns the sum of the whole DataSet
=Sum(Fields!TestField.Value, "YourDataSetName")
'Returns the sum of a group
=Sum(Fields!TestField.Value, "YourGroupName")
You can also stack them:
=Sum(Sum(Fields!TestField.Value, "Level3GroupName"), "Level2GroupName")
I have a bit of an interesting problem.
I required the cumulative sum on a set that is created by pieces of a Time dimension. The time dimension is based on hours and minutes. This dimension begins at the 0 hour and minute and ends at the 23 hour and 59 minute.
What I need to do is slice out portions from say 09:30 AM - 04:00 PM or 4:30PM - 09:30 AM. And I need these values in order to perform my cumulative sums. I'm hoping that someone could suggest a means of doing this with standard MDX. If not is my only alternative to write my own stored procedure which forms my Periods to date set extraction using the logic described above?
Thanks in advance!
You can create a secondary hiearchy in your time dimension with only the hour and filter the query with it.
[Time].[Calendar] -> the hierarchy with year, months, day and hours level
[Time].[Hour] -> the 'new' hierarchy with only hours level (e.g.) 09:30 AM.
The you can make a query in mdx adding your criteria as filter :
SELECT
my axis...
WHERE ( SELECT { [Time].[Hour].[09:30 AM]:[Time].[Hour].[04:00 PM] } on 0 FROM [MyCube] )
You can also create a new dimension instead of a hierarchy, the different is in the autoexists behaviour and the performance.