Result of the Sum of all elements mdx query incorrect Analysis Service Cube - mdx

i got a weird issue with my olap cube by issuing a mdx query.
You can see that the following mdx query is generated by excel:
SELECT NON EMPTY Hierarchize({DrilldownLevel({[BuchungskreisWerk].[Quelle].[All]},,,INCLUDE_CALC_MEMBERS)})
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON EMPTY
Hierarchize({DrilldownLevel({[BuchungskreisWerk].[Buchungskreis mit Text].[All]},,,INCLUDE_CALC_MEMBERS)})
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON ROWS FROM
(SELECT ({[BuchungskreisWerk].[Buchungskreis mit Text].&[48], [BuchungskreisWerk].[Buchungskreis mit Text].&[49], [BuchungskreisWerk].[Buchungskreis mit Text].&[207], [BuchungskreisWerk].[Buchungskreis mit Text].&[221]})
ON COLUMNS FROM [Bestbew_Global])
WHERE ([Measures].[Lagerbestand]) CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
The output table looks as follows:
Output in Excel
So as we can see the total of B1 and R3 are correct.
But the sum of all resulst, which should be B1+R3 is B1 only.
Anyone has an idea where this error could came from?

Related

Calculated measure hurting performance and returning many more rows

I have the following query which should be returning income split by country and date. It should also be including a count of the number of dates in the grouping. This would be useful for a calculation looking at an entire month of income/days. I'm finding that the calculated measure is causing all countries in the dimension to be returned regardless of if there's any income data for it. Is there any way to limit this so only countries with income are returned?
with
MEMBER [Measures].[group_day_count] as
COUNT(
Descendants(
[Date].[Date].currentmember, [Date].[Date].[Date]
)
)
SELECT NON EMPTY Hierarchize({DrilldownLevel({[Date].[Date].[All]},,,INCLUDE_CALC_MEMBERS)})
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME,
[Date].[Date].[Date].[Date Sort] ON COLUMNS ,
NON EMPTY CrossJoin(Hierarchize({DrilldownLevel({[Source Location].[Country Code].[All]},,,INCLUDE_CALC_MEMBERS)}),
{[Measures].[group_day_count],[Measures].[income]})
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON ROWS
FROM (SELECT ({[Date].[Date].&[2017-10-04], [Date].[Date].&[2017-10-05], [Date].[Date].&[2017-10-06], [Date].[Date].&[2017-10-07], [Date].[Date].&[2017-10-08], [Date].[Date].&[2017-10-09], [Date].[Date].&[2017-10-10]})
ON COLUMNS FROM [Placeholder])
CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
Try:
IIF([Measures].[Income],[Measures].[Days],NULL)

MDX : Rename column titles as calculated Mmeber

I have an OLAP Mondrian cube published on JasperServer within MDX script
My cube looks like this:
The MDX code is the following:
select NON EMPTY {[Measures].[Time consumed]} ON COLUMNS,
NON EMPTY Hierarchize({([Users.User].[All Users.Users],[Projects.Project].[All Projects.Projects],[Tasks.Task].[All Tasks.Tasks], [Imputations.Imputation].[All Imputations.Imputations])}) ON ROWS
from [cubeSifast]
As I see in the display view i have standr columns nomination, so how may I change for example :
1. the column headers titles (circled with blue line)
2. the children titles which are the names of dimensions (yellow)
I think that can be within the calculated members with MDX
"with member as"
but how exatcly, any suggestions?
You could try it with a Set.
with
set myNewName
as
[Users.User].[All Users.Users].MEMBERS
select
NON EMPTY {[Measures].[Time consumed]} ON COLUMNS,
NON EMPTY Hierarchize({(myNewName,[Projects.Project].[All Projects.Projects],[Tasks.Task].[All Tasks.Tasks], [Imputations.Imputation].[All Imputations.Imputations])}) ON ROWS
from [cubeSifast]

Cross join same hierarchy columns

I have a SQL data cube with following hierarchy
I want to cross join Warehouse division and Code warehouse Desc. I wrote a MDX as follows
SELECT NON EMPTY
{ [Measures].[Total Value]}
DIMENSION PROPERTIES CHILDREN_CARDINALITY,
PARENT_UNIQUE_NAME ON COLUMNS,
NON EMPTY
{
[Combined].[Drill Down Path 4].[Warehouse Division].MEMBERS* [Combined].[Drill Down Path 4].[Code Warehouse Desc].MEMBERS
}
DIMENSION PROPERTIES MEMBER_CAPTION ON ROWS FROM [InventoryAge]
WHERE ( [Calendar].[Report Days].[All Members].&[All].&[WantInReport].& [2].&[20141031] )
It gives me an error as follows
Query (13, 8) The Drill Down Path 4 hierarchy is used more than once in the Crossjoin function.
Can any body suggests a better way to do this
Please find the calender hierarchy
You don't need to crossjoin hierarchy (this is impossible) to do what you need. Just query the lowest level of it, you will get all parents also
SELECT NON EMPTY
{ [Measures].[Total Value]}
DIMENSION PROPERTIES CHILDREN_CARDINALITY,
PARENT_UNIQUE_NAME ON COLUMNS,
NON EMPTY
{
[Combined].[Drill Down Path 4].[Code Warehouse Desc].allMEMBERS
}
DIMENSION PROPERTIES MEMBER_CAPTION ON ROWS FROM [InventoryAge]
WHERE ( [Calendar].[Report Days].[All Members].&[All].&[WantInReport].& [2].&[20141031] )
PS. You might not be able to see them in SSMS query result viewer, but they will appear if you use query in cube browser or as dataset in SSRS/other tool
You can pass last date in your set by using Tail(Existing [Calendar].[Report Days].[All Members].&[All].&[WantInReport].members, 1).item(0)
Or you can use Format(Now()), which gives you string representation of current system date. However, it depends on locale, so you probably need to remove dots/slashes. See here

MDX Query Optimization

I have a pivot table generated in Excel. I need to use the same MDX query which is used in Excel, I have extracted the same query from Excel which is like this -
SELECT {[Measures].[OQ],[Measures].[RQ],[Measures].[SQ],[Measures].[SRQ]}
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS ,
CrossJoin(
CrossJoin(
CrossJoin(
CrossJoin(
CrossJoin(
CrossJoin(
CrossJoin(
Hierarchize({DrilldownLevel({[PO].[Date].[All]},,,INCLUDE_CALC_MEMBERS)}),
Hierarchize({DrilldownLevel({[PO].[Priority].[All]},,,INCLUDE_CALC_MEMBERS)})),
Hierarchize({DrilldownLevel({[POL].[Container].[All]},,,INCLUDE_CALC_MEMBERS)})),
Hierarchize({DrilldownLevel({[PO].[Name].[All]},,,INCLUDE_CALC_MEMBERS)})),
Hierarchize({DrilldownLevel({[POL].[Num].[All]},,,INCLUDE_CALC_MEMBERS)})),
Hierarchize({DrilldownLevel({[PO].[Warehouse].[All]},,,INCLUDE_CALC_MEMBERS)})),
Hierarchize({DrilldownLevel({[POL].[Status].[All]},,,INCLUDE_CALC_MEMBERS)})),
Hierarchize({DrilldownLevel({[POL].[Factor].[All]},,,INCLUDE_CALC_MEMBERS)}))
ON ROWS
FROM [Purchases] CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
This query returns about 3 lac records in excel, when I run this query in SSMS it gives error like "Server: The operation has been cancelled due to memory pressure.".
I am new to MDX, above query uses many CrossJoins, is there any way to optimize this query?
Thanks and Regards,
Amit Thakkar
I think its result maybe unusable almost for statistic reason
because of returning many rows.
but for optimization I suggest using
NONEMPTY
front of your crossjoin

Adding an extra row to an MDX result set

I have a very simple MDX query that retuns the contents of a dimension.
I would like to inject one more row to the result set as part of the MDX.
Is this possible?
You can create a calculated member of the dimension. Suppose I have 4 members of region built into my cube: East, West South and Central.
SELECT
{[Profit].[Sales]} ON COLUMNS,
NON EMPTY [Market].Generations(2).Members ON ROWS
FROM [Basic]
will give me the sales over the 4 regions.
If I add a dummy calculated member to the region, I can get one extra row of results.
WITH
MEMBER [Market].[Dummy] AS
'0',
SOLVE_ORDER = 0
SELECT
{[Margin].[Sales]} ON COLUMNS,
NON EMPTY Union(
[Market].Generations(2).Members,
{[Market].[Dummy]}) ON ROWS
FROM [Basic]
no, it has to be a member of some dimension