Calculated member roll up
I am working on an MDX query that is giving me some trouble. The business requirements are to identify a target value of a measure. The target is determined as the minimum value for the measure within the last 6 months. I've accomplished identifying the
target values per month using the following query:
WITH MEMBER [Measures].[Target Value] AS MIN
[Date].[Month Hierarchy].PrevMember.Lag(5) :
[Date].[Month Hierarchy].PrevMember,
[Measures].[Source]
SELECT [Measures].[Target Value] ON 0,
{[Date].[Month Hierarchy].[Month].&[201407],
[Date].[Month Hierarchy].[Month].&[201406]} ON 1
FROM [Cube]
The results are:
The data being returned is correct. However, I'm not sure where to go from here. I want to be able to roll up these values based on a date range that will be passed in as the slicer axis. Removing the date range from Axis 1 results in an error.
So, how can I get these values to roll up based on a date range in the slicer axis and with no Axis 1?
Lefka
Hi Lefka,
According to your description, you want to calculate the toatl target for those months which under the date range, right?
In this case, you can use the SUM function to achieve your requirement. I have tested it on my local environment, the following sample query if for you reference.
WITH MEMBER [Measures].[Target Value] AS MIN
[Date].[Calendar].PrevMember.Lag(2) :
[Date].[Calendar].PrevMember,
[Measures].[Internet Order Quantity]
MEMBER [measures].[TotalTarget]
AS
SUM({[Date].[Calendar].[Month].&[2006]&[8]:[Date].[Calendar].[Month].&[2007]&[4]},[Measures].[Target Value] )
SELECT {[Measures].[TotalTarget]} ON 0
FROM [Adventure Works]
Result
If I have anything misunderstand, please point it out.
Regards,
Charlie Liao
TechNet Community Support
Similar Messages
-
Calculated member not displaying
I have a calculated member that has a case statement with many many when clauses. I have included a part of the code below. But when a member doesn't exists in the "Beginning Buildings" calculated member doesn't appear in the cube as a measure.
If I comment out the lines where the member doesn't exists then I can see the calculated member in the cube.
So on the code below if I comment out the first when clause that has [FEB Estimate] in the Edition dimension I can see the calculated member in the cube. The Edition dimension doesn't have this member anymore but since is in a CASE statement it should
not find it still display the member.
CREATE MEMBER CURRENTCUBE.[Measures].[Beginning Buildings]
AS
case
when [Dim Edition].[Editions].CurrentMember is [Dim Edition].[Editions].[Qtr].&[FEB Estimate]&[1]
then SUM([Dim Edition].[Editions].[Month].&[Year12 Actuals]&[4]&[12], [Measures].[base Buildings In Inventory])
when [Dim Edition].[Editions].CurrentMember is [Dim Edition].[Versions].[Qtr].&[Year13 Budget]&[1]
then SUM([Dim Edition].[Editions].[Month].&[Year12 Actuals]&[4]&[12], [Measures].[base Buildings In Inventory])
else
SUM([Dim Edition].[Editions].Prevmember, [Measures].[base Buildings In Inventory])
end
FORMAT_STRING
= "#,##0",
VISIBLE
= 1, DISPLAY_FOLDER = 'Building';maybe I didn't explain it clearly but say I have this
case
when [Dim
Edition].[Editions].CurrentMember
is [Dim Edition].[Editions].[Qtr].&[FEB
Estimate]&[1]
then SUM([Dim
Edition].[Editions].[Month].&[Year12
Actuals]&[4]&[12],
[Measures].[base
Buildings In Inventory])
when [Dim
Edition].[Editions].CurrentMember
is [Dim Edition].[Versions].[Qtr].&[Year13
Budget]&[1]
then SUM([Dim
Edition].[Editions].[Month].&[Year12
Actuals]&[4]&[12],
[Measures].[base
Buildings In Inventory])
else
SUM([Dim Edition].[Editions].Prevmember,
[Measures].[base
Buildings In Inventory])
end
the calculated measure doesn't this play
but if I have this
case
when [Dim
Edition].[Editions].CurrentMember
is [Dim Edition].[Editions].[Qtr].&[FEB
Estimate]&[1]
then SUM([Dim
Edition].[Editions].[Month].&[Year12
Actuals]&[4]&[12],
[Measures].[base
Buildings In Inventory])
else
SUM([Dim Edition].[Editions].Prevmember,
[Measures].[base
Buildings In Inventory])
end
the calculated measure displays.
Why is that?
I have another cube that has the same type of case statement and it displays even though some case statements are not meet. -
How to display a percentage sign in calculated member column?
Hello all,
in my report I have a calculated member column whose value is determined by follwing value formula:
if CurrentColumnIndex - 2 = 1 then
If GridValueAt(CurrentRowIndex, CurrentColumnIndex-3, CurrentSummaryIndex) = 0 then
0
else
(GridValueAt(CurrentRowIndex, CurrentColumnIndex-1, CurrentSummaryIndex)/
GridValueAt(CurrentRowIndex, CurrentColumnIndex-3, CurrentSummaryIndex)) * 100
else
If GridValueAt(CurrentRowIndex, CurrentColumnIndex-5, CurrentSummaryIndex) = 0 then
0
else
(GridValueAt(CurrentRowIndex, CurrentColumnIndex-1, CurrentSummaryIndex)/
GridValueAt(CurrentRowIndex, CurrentColumnIndex-5, CurrentSummaryIndex))*100
Returned is a numeric value and it is being correctly displayed in calculated member column. As the value should represent percentage, I need to display a % sign after every value.
How would I achieve this? I have seen a thread here in the discussion where approach with a formula and DisplayString function is mentioned - but there are no details how this could be achieved....
The crosstab in question looks like this:
Calculated Member is based on "REV_TOTAL" group column.
I also attached the .rpt file (renamed to .txt for upload)
Many thanks in advance,
MarinHello Raghavendra,
thanks for the quick reply.
Unfortunately it is not as easy at it seems - calculated member column is not showing in report designer and I can not apply the suggested approach with formatting toolbar...
The column only shows here (right click on table -> "Advanced Calculations" -> "Calculated Member...") and there is no possibility to format it directly:
Any other suggestions?
Many thanks,
Marin -
Running Total of a Calculated Member
Hi Friends ,
Need help in calculating the Running Total of a calculated member . I am using the below Query to calculate but it is not showing correct Values.
Query :
WITH
set
[FUNCTIONAL BENEFITS]
as
ORDER(
[FUNCTIONAL BENEFITS].[FUNCTIONAL BENEFITS].children,[Measures].[ANNUAL UNIT CASES WEIGHTED VALUE]
,DESC)
member AUCWEIGHT as
[Measures].[ANNUAL UNIT CASES WEIGHTED VALUE],
FORMAT_STRING='##0.0'
member
[Running Total]
AS
SUM({null:[FUNCTIONAL BENEFITS].[FUNCTIONAL BENEFITS].CurrentMember},[Measures].[ANNUAL UNIT CASES WEIGHTED VALUE]),
FORMAT_STRING='##0.0'
MEMBER [Measures].[AUCWV_PRCT] AS
([Running Total]/[Measures].[TotalSuM])*100,
FORMAT_STRING='##0.0'
member [CummalativePercent] as
(SUM({null:[FUNCTIONAL BENEFITS].[FUNCTIONAL BENEFITS].currentmember},[Measures].[AUCWV_PRCT]))
SELECT {
AUCWEIGHT,[Running Total],
[Measures].[TotalSuM],[Measures].[AUCWV_PRCT],[CummalativePercent]}on columns,
NON EMPTY ([FUNCTIONAL BENEFITS])
DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON rows
FROM [RRMiningDS1_CUBE]
Output :
DiMENSION
AUCWEIGHT
RunningTotal
TotalSum
AUCWV_PRCT
CUMMULATIVEPERCENT
CORRECTCUMMULATIVEPERCENT
A
62605.4
661634.6
1345632.2
49.2
1271.2
49.2
B
38587.9
425278.7
1345632.2
31.6
545.5
80.8
C
35894.5
370057.9
1345632.2
27.5
485.2
108.3
D
30246.4
48345.3
1345632.2
3.6
4.9
111.9
The CUMMALITIVEPERCENT is coming wrong .
I have mentioned the Correct CummulativePercent. as it should be the Running sum of AUCWV_PRCT i.e
49.2+31.6+27.5+3.6=111.9
Please help . where i am making the mistake
Thanks
Rakesh k DharHi R,
It might be as simple as adding solve_order = 99 to the cumulative calc. This tells the formula engine to do the cumulative calculation after the %.
Richard -
When is a dimension memeber a calculated member?
Hey folks,
I created some master data., but I can't see (yet) any logic, if a member is a calulated member (in refernece to master data table, Flag "Calculated member").
When is this set to N, when to Y?
How can I influence/change this?
Thanks in advance!
ChristianThanks for the reply. So far, this was my opinion, too.
But, I have the following hierarchy:
ID EVDESCRIPTION PRODGRP SCALING PARENTH1
ALLPROD
MUSTARD Mustrad Food ALLPROD
KETCHUP Kecthup Food ALLPROD
MAYONAISSE Mayhonnaise Food ALLPROD
BROOM Broom Household ALLPROD
MOP Mops Household ALLPROD
DUSTPAN Dustpans Household ALLPROD
In my opinion, the 6 entries (MUSTARD-DUSTPAN) are non-calculated members. Dimension member ALLPROD is a calculated member.
But when I had a look into master data table I saw, that the calculated member-flag for ALLPROD is N as well, which needs to be Y in my opinion.
ALLPROD EN N H1
BROOM EN N H1 Household Broom
DUSTPAN EN N H1 Household Dustpans
KETCHUP EN N H1 Food Kecthup
MAYONNAISE EN N H1 Food Mayhonnaise
MOP EN N H1 Household Mops
MUSTARD EN N H1 Food Mustrad
Why is the calculated-member-flag for ALLPROD = N, as ALLPROD is the root-Element of alle Products?
Any further help is appreciated.
Best Rgds,
Christian -
Help in creating MDX Calculated Member using attributes from multiple Dimension
Hi All,
First of all my knowledge on MDX is basic. In one of our projects, there is a requirement to create calculated member (similar to derived fields in SQL) which is more of a dimension attribute and not really a calculated member. Due to IP issues I cannot paste
the actual queries but I will provide an SQL Query equivalent to what I am trying to achieve:
Select P.Product, Case When ISNULL(FS.ArtistName,'') = '' Then P.ArtistName Else FS.ArtistName End Artist
From
dbo.FactMusicSales FS
Join dbo.dimProduct P
on P.DimProductKey = FS.DimProductKey
We are trying to replicate the logic for derving the "Artist" field using MDX script.
We are running into issues while trying to build an MDX expression using the above logic. The main issue being that the new field/member "Artist" would not be calculated unless its elements are selected (FS.ArtistName, P.ArtistName). Besides this
we are also unable to place this new member in a different folder other than a sub folder under the measures. Any pointers to solving this would be really helpful.
Thanks in Advance,
VenkiHi Venki,
According to your description, you need to create calculated member (similar to derived fields in SQL) which is more of a dimension attribute and not really a calculated member, right?
In your scenario, you needn't to achieve this requirement by using MDX. You can use a named query on your data source view. A named query is a SQL expression represented as a table. In a named query, you can specify an SQL expression to select rows and columns
returned from one or more tables in one or more data sources. So in you scenario, you can use your query on the DSV, and then use the modified table to create a dimension.
http://msdn.microsoft.com/en-IN/library/ms175683.aspx
Regards,
Charlie Liao
TechNet Community Support -
MDX Calculated Member With Multiple Conditions
I need to create a calculated member in my cube that spans multiple dimensions. A current calculated member looks like this:
[Employee Hours Category].[Utilization Category].[NON-PTO], [Measures].[Employee Hours]
This calculated member returns all the hours an employee worked that are not PTO.
I need to select employee hours but with multiple conditions:
- [DIM BILL STATUS][Bill Status] equals 0
- [Employee Hours Time Category].[Time Category] equals "Client Facing"
- [DIM PROJECT].[Client] isn't like "Olson"
I know this is probably pretty easy, but I'm horrible with MDX!
Thank you!!
A. M. RobinsonThank you...
Your answer looks good but I was actually able to figure out most of it, but still looking how to incorporate a FILTER into the MDX. I would like to FILTER like this:
FILTER ([DIM Project].[Client].[Client].Members ,
NOT InStr([DIM Project].[Client].CurrentMember.MEMBER_NAME, "Olson")
Heres the MDX I have so far that is working fine:
([Employee Hours Time Category].[Time Category].&[Client Facing],
[DIM BILL STATUS].[Bill Status ID].&[1], [Measures].[Employee Hours])
Do you just wrap the whole MDX in the filter, and if so, how would that be formatted?
A. M. Robinson -
New calculated member based on existing measure and a dimension value
Hi
I’m trying to create a new calculated member in my cube based on an existing measure and a dimension value.
I can do it easily in DSW but I want to do it as a Calculated Member in Calculations tab from my cube.
I have a dimension called Product in which one attribute is UOM (unit of measure) and a measure called Quantity. The relationship with the fact table is “Regular”.
For each product we have a unit of measure and an associated quantity measure:
Product Name
UOM Quantity
Product 1
Km
50
Product 2
Kg
60
Product 3
Kw
25
Product 4 L
15
Product 5 T
1.5
Total 151.5
The calculated member I want to create is “Kw” and has to contain the value from Quantity measure when Product.UOM is “kW” and should look like this:
Product Name
UOM Quantity
Kw
Product 1
Km
50
Product 2
Kg
60
Product 3
Kw
25
25
Product 4 L
15
Product 5 T
1.5
Total 151.5
25
So far I tried using the MDX with “IIF” or “Case” but with no results.
What statement I should use in this case?
Thank you.Hi Cees,
Thank you for your answer.
I never used yet the “Scope” statement and yet it’s an elegant solution.
I use it as in your example:
CREATE
MEMBER CURRENTCUBE.[Measures].[Kw]
AS NULL,
FORMAT_STRING =
VISIBLE = 1 ,
ASSOCIATED_MEASURE_GROUP =
'TR Other';
Scope [Measures].[Kw];
Scope [Product].[UOM].[kW];
This = [Measures].[Quantity];
End
Scope;
End
Scope;
…and the calculations are solid…with one exception: when I took out UOM from the query there are no more any resuts:
Product Name Quantity Kw
Total
It’s only working
if using UOM in the query.
I also thought that a
tulpe might be another solution as:
([Measures].[Quantity],[Product].[UOM].&[kW])
On this last one I’ve got the expected results with one exception: when I use UOM in the query all the other UOM values are listed each one of them
having the [Kw] measure calculation value.
Product Name UOM Quantity Kw
Product 1 Km
50
Product 2 Kg
60
Product 3 Km
25 25
Product 3 Kg
25 25
Product 3 Kw
25 25
Product 3 L
25 25
Product 3 T
25
25
Product 4 L
15
Product 5 T
1.5
Total 151.5
25
…and without UOM in the query I have what I’m expected:
Product Name Quantity
Kw
Product 1 50
Product 2 60
Product 3 25
25
Product 4
15
Product 5
1.5
Total 151.5
25
Maybe we can work together to find a solution.
Thank you,
Oks -
CR 2011 - calculated member in cross tab
Hello,
I have created a cross tab in my report and added a calculated member. I have created a formula for all my rows because by default the value of the calculated member was "0". Now I wanted to add a new row to my report. The value in the calculated member now is not "0" but empty. How can I access the formula workshop now?
Can anybody help?
Thanks and regards,
Juleif you right click on the cross-tab > go to Advanced Calculations > Calculated Member > click on the one that you want to edit and press the Edit Value Formula button
cheers,
jamie -
Cross Tab with Calculated Member Fails in BO Enterprise
Hello,
I have a report (Crystal Reports 2008) that I created using a cross tab, with a calculated member field. This report runs fine on my desktop, but fails when published to Crystal Enterprise (Server 2008).
When scheduled, the instance history states Crystal Reports: Print Engine Error
When I remove the calculated member from the cross tab, it runs fine.
Has anyone come across this and if so, how did you resolve it? I believe this is a brand new feature in Crystal Reports 2008 - is it not supposed within Enterprise?
Thank you for your assistance.Root Cause: I had built my report in Crystal Reports 2008 on the latest Service Pack/Fix Packs (which addressed the issue of calculated member). My Crystal Reports SERVER 2008 was on a lower version.
I opened a message with SAP support and they were unable to tell me how to apply service packs to my Server. They then pretty much abandoned my question, so below is what I came up with on my own to fix the issue.
There are no specific service packs/ hot fixes for Crystal Reports SERVER 2008, so I had to:
1) install Crystal Reports V0 on my CRS 2008 machine
2)Install all Service Pack/Fix Packs available for Crystal Reports 2008 (even SP1, even though all SAP documentation tells you not to do this, it is required before you can install SP2)
3) Reboot Server
If you do the same thing as me, just a warning that installing the Crystal Reports SPs will break InfoView/CMC until you apply them all and re-boot. -
MDX Query to Calculated member
Hi All,
I have a MDX query which works fine, when converting the query to Calculated member, I get the same result for all the rows of a dimension.
select {[Measures].[Contents]} on 0,
([Dim Products].[Product Alias].[Product Alias].members,
(filter ([Dim Products].[Product ID].members,
instr(left([Dim Productss].[Product ID].currentmember.member_Key,3),'112')>0))) on 1
from
<<CubeName>>
Calculated Member:
SUM(filter ([Dim Products].[Product ID].members,
instr(left([Dim Products].[Product ID].currentmember.member_Key,3),'112')>0),[Measures].[Contents])
When I drag the dimension product, the calculated member showing the same result for all the products. Can anyone let me know the syntax error here.Hi SQL GUN,
For me it works :
WITH MEMBER [Last3MonthsInternetSales] AS
AGGREGATE
LastPeriods(-3, ClosingPeriod([Date].[Calendar].[Month], [Date].[Calendar].[Month].&[2005]&[12])),
[Measures].[Internet Sales Amount]
SET MySet AS
{[Date].[Calendar].[Month].&[2005]&[09],
[Date].[Calendar].[Month].&[2005]&[10],
[Date].[Calendar].[Month].&[2005]&[11],
[Date].[Calendar].[Month].&[2005]&[12],
[Date].[Calendar].[Month].&[2006]&[01],
[Date].[Calendar].[Month].&[2006]&[02]}
SELECT
[Measures].[Internet Sales Amount],
[Last3MonthsInternetSales]
} ON COLUMNS,
MySet
} ON ROWS
FROM [Adventure Works]
Are u sure your query is correct. I think you might have a [Fiscal Month Num of Year] too much in your (). I'm not sure, but are u dragging the correct level of hierarchy ? Also in the part ON ROWS you seem to take a lot of levels with you.
Why for example take .allmembers when you only want the actual last 3 of your currentmember?
Can u check again? -
Difference Between Calculated Member and Embedded summary
Hi,
Can anyone explain me the difference between the Calculated Member and Embedded summary. Please also clarify when to use which one.
The issue I am having a crosstab report displaying sales revenue for product over the years.
I have my years in columns, product in rows and sales revenue in summarized field. There are 10 products in my report. Its static as of today.
I have to group the first 4 products and display the sub total over the years. Similarly I have to group the last 6 products and display the sub total over the years in the cross tab.
I have to display a column next to the sales revenue having the percentage contribution by the product to that group that I have created earlier.
How to achieve the same.
Thanks and Regards,
Subbu SPlease re-post if this is still an issue to the Crystal Report Design Forum or purchase a case and have a dedicated support engineer work with you directly
-
SSAS 2012 Calculated Member in "hh:mm:ss" does not work
I've seen a lot of posts that suggest this should work for displaying a calculated member in hours:minutes:seconds, but it doesn't in my 2012 developer environment. I don't care that this specific code isn't accurate if the duration in seconds is over
a day long at this point. It seems no matter how I try to format this, the result is the same.
[Measures].[Phase Duration Seconds] is an integer, and it doesn't seem to matter what goes in the FORMAT_STRING parameter, it comes out in SSMS, and SSDT as a decimal number.
CREATE MEMBER CURRENTCUBE.[Measures].[Phase Duration]
AS [Measures].[Phase Duration Seconds] / 86400,
FORMAT_STRING = "hh:mm:ss",
VISIBLE = 1 ;
If I write this as an MDX script, it works in SSMS, with or without the extra code to account for durations beyond a day:
with member [Measures].[Phase Duration] as [Measures].[Phase Duration Seconds] / 86400,
format_string = IIF([Measures].[Phase Duration Seconds] / 86400 < 1,'"0 days" hh:mm:ss','"' + cstr(int([Measures].[Phase Duration Seconds] / 86400)) + ' days" hh:mm:ss')
select
[Measures].[Phase Duration Seconds],
[Measures].[Phase Duration]
} on 0,
[Phase].[Phase].Members
} on 1
from [SSASDB]
Cheers and many thanks for any guidance,
SimonAfter much trial and error, am I just barking up the wrong tree?
I just learned about the deprecation of the abilities of the browser in Analysis Services 2012, and started using Excel instead... The original code above to create a calculated member does work in Excel.
Cheers and thanks,
Simon
Cheers and thanks, Simon -
Translation for calculated member
Hi,
is there any way to set language captions for a calculated member?
many thanks!Hi,
Yes you can set translation even for a calculated member.
If you go to Translation tab in BIDS you will find all the calculated members at the bottom. Add a new translation and give the caption as you wish.
Let us know if you still face issues.
Thanks,
Rajasekhar -
I'm using SQL Server 2012. I have noticed that commenting out calculated member formulas in BIDs (like even just 10 lines of formula) can cause BIDs to throttle all the CPU and become unresponsive for minutes. What could be the cause of that?
Hi Lee,
According to your description, you get high CPU usage when commenting out the calculated member formulas. Right?
With your information, we are not sure this is a MDX Query performance issue or the BIDS issue. We suggest you optimize your MDX query and diagnose the Formula Engine performance. Please refer to the links below:
Query Performance Tuning in Microsoft Analysis Services: Part 2
Analysis Services Query Performance Top 10 Best Practices
If possible, please post some screenshots or detail information about calculated member formulas so that we can have some deep analysis.
Best Regards,
Simon Hou
Simon Hou
TechNet Community Support
Maybe you are looking for
-
LCD Problem -- Replace display or use MBP as desktop?
Internal video is usually dead on my MBP 3,1 -- dark grey screen (but not black) with various vertical stripes. External display works fine. Internal display periodically comes back to life for no apparent reason but then fades back to its usual unhe
-
Tip: How to link to a non-iWeb page in the main navigation menu.
I've figured out an easy way to add a link to the main navigation menu which links to a URL of your choosing. For example, I have an older .Mac site using the now archaic HomePage. Instead of rebuilding all of my old pages in iWeb, I thought it would
-
i have a hp pavilion dv7-1130us and it has crashed. was my late mother-in-law & we do not have the disc that came with the notebook. Screen is asking for book disk...I do not have it. Any assistance is appreciated.
-
Updated to 10.5.7 and my Printer can't be found
I recently updated my MacPro with a fresh install of OSX from my system disc and subsequently went through the update process to bring it up to 10.5.7. Among other problems, my printer (an Epson RX580) connected over USB can't be found. I reinstalled
-
Mantaining closed the query structure when launching a query from "query mg
Hi, Is it possible to maintain closed the query structure window when launching a query from the "Query manager" menu? As say, if I want to see the query syntax, I must click on the "Display query structure" symbol. Now the query results windows, alw