Results of MDX query against missing partition - Tabular 2012 - mdx

UPDATE: the resolution was to do a process full at the database level instead of at the partition level.
I am trying to understand the behavior I am observing with a query a Tabular model. I partition by quarter, so when I built a new "current quarter" partition at the start of this quarter, the partition that used to contain 2016-Q4 was overwritten with 2017-Q1. Then when I ran my MDX query against the Tabular model filtering on the date dimension for 2016-Q4, instead of returning nothing like I would have expected, it returned data from the oldest partition 2014-Q1. It is like instead of returning no data, it decides to return the "first record" for that dimension (in this case all dates where 07/01/2014). Every other dimension I was filtering on still performed as expected.
Does anybody have any ideas as to why it behaves this way? FYI, I have tried restructuring my MDX statement a couple different ways:
SELECT
NON EMPTY { [Measures].[Measure1]} ON COLUMNS,
NON EMPTY { ([Dimension].[Dimension1])} DIMENSION PROPERTIES member_caption, member_unique_name ON ROWS
FROM [Model] WHERE ([Dimension].[Dimension2].&[Value], [DateDimension].[DateDimension].&[Value1] : [DateDimension].[DateDimension].&[Value2])
AND
SELECT
NON EMPTY { [Measures].[Measure1]} ON COLUMNS,
NON EMPTY { ( except([Dimension].[Dimension1].members,[Dimension].[Dimension1].[all]))} DIMENSION PROPERTIES member_caption, member_unique_name ON ROWS
FROM ( SELECT ( [Dimension].[Dimension1].&[Value] ) ON COLUMNS
FROM ( SELECT ( [Dimension].[Dimension2].&[Value] ) ON COLUMNS
FROM ( SELECT ( [DateDimension].[DateDimension].&[Value1] : [DateDimension].[DateDimension].&[Value2] ) ON COLUMNS
FROM [Model])))
Edit: added example of actual MDX
SELECT
NON EMPTY { [Measures].[ConvertedNetRevenue],
[Measures].[LoadConvertedNetRevenue],
[Measures].[OrderConvertedNetRevenue],
[Measures].[TotalOrderBrokerageCount],
[Measures].[TotalLoadBrokerageCount]
} ON COLUMNS,
NON EMPTY {
(
except([BrokerageQuery].[KeyBranch].members,[BrokerageQuery].[KeyBranch].[all]),
except([BrokerageQuery].[LoadNumber].members,[BrokerageQuery].[LoadNumber].[all]),
except([BrokerageQuery].[CustomerOrderNumber].members,[BrokerageQuery].[CustomerOrderNumber].[all]),
except([BrokerageQuery].[BranchName].members,[BrokerageQuery].[BranchName].[all]),
except([BrokerageQuery].[BranchCode].members,[BrokerageQuery].[BranchCode].[all]),
except([BrokerageQuery].[BranchRoleDescription].members,[BrokerageQuery].[BranchRoleDescription].[all]),
except([BrokerageQuery].[ModeDescription].members,[BrokerageQuery].[ModeDescription].[all]),
except([BrokerageQuery].[ServiceTypeDescription].members,[BrokerageQuery].[ServiceTypeDescription].[all]),
except([BrokerageQuery].[SystemDisplayName].members,[BrokerageQuery].[SystemDisplayName].[all]),
except([BrokerageQuery].[IsPartialFinLock].members,[BrokerageQuery].[IsPartialFinLock].[all]),
except([BrokerageQuery].[KeyDate_Financial].members,[BrokerageQuery].[KeyDate_Financial].[all])
)
} DIMENSION PROPERTIES member_caption, member_unique_name ON ROWS
FROM ( SELECT
(
{
[dimCurrency].[CurrencyCode].&[USD]
}
) ON COLUMNS
FROM ( SELECT
(
{
{
[BrokerageQuery].[KeyBranch].[10279]
}
}
) ON COLUMNS
FROM ( SELECT
(
[BrokerageQuery].[KeyDate_Financial].&[20161106] :
[BrokerageQuery].[KeyDate_Financial].&[20161106]
) ON COLUMNS
FROM [Brokerage])))

Instead of processing our partitions individually (at the beginning of each quarter when re-partitioning occurs), we need to do a database-level process full.

Related

Essbase MDX queries not matching

I am using a BI tool that auto-generates MDX code for an Essbase data source. I am running two queries that should bring back the same numbers, but I get different numbers.
The first query brings back results by month for 12 months of the year and produces incorrect results:
SELECT
NON EMPTY
{
[Jan]
,[Feb]
,[Mar]
,[Apr]
,[May]
,[Jun]
,[Jul]
,[Aug]
,[Sep]
,[Oct]
,[Nov]
,[Dec]
}
DIMENSION PROPERTIES
[MEMBER_UNIQUE_NAME]
,[MEMBER_CAPTION]
,[GEN_NUMBER]
,[LEVEL_NUMBER]
ON COLUMNS
,NON EMPTY
Descendants
(
[ABOVE]
,[ABOVE].Level
,AFTER
)
DIMENSION PROPERTIES
[MEMBER_UNIQUE_NAME]
,[MEMBER_CAPTION]
,[GEN_NUMBER]
,[LEVEL_NUMBER]
ON ROWS
FROM [F_IntPrf].[F_IntPrf]
WHERE
(
[ALL_TERRITORY]
,[ALL_PS_BUS_AFF]
,[ALL_PS_BUS]
,[Input Currency]
,[MayFC]
,[FY17]
,[Forecast]
,[USDRep]
);
The second query shows the results for January only, and produces the correct results :
SELECT
NON EMPTY
Descendants
(
[ABOVE]
,[ABOVE].Level
,AFTER
)
DIMENSION PROPERTIES
[MEMBER_UNIQUE_NAME]
,[MEMBER_CAPTION]
,[GEN_NUMBER]
,[LEVEL_NUMBER]
ON COLUMNS
FROM [F_IntPrf].[F_IntPrf]
WHERE
(
[Jan]
,[ALL_TERRITORY]
,[ALL_PS_BUS_AFF]
,[ALL_PS_BUS]
,[Input Currency]
,[MayFC]
,[FY17]
,[Forecast]
,[USDRep]
);
What am I doing wrong in the first query ?
Thank you!
To focus in on the problem I would start by comparing two very simple queries such as these two:
SELECT
NON EMPTY
{
[Jan]
}
ON COLUMNS
,NON EMPTY
Descendants
(
[ABOVE]
,[ABOVE].Level
,AFTER
)
ON ROWS
FROM [F_IntPrf].[F_IntPrf]
WHERE
(
[ALL_TERRITORY]
);
versus this...
SELECT
NON EMPTY
Descendants
(
[ABOVE]
,[ABOVE].Level
,AFTER
)
ON COLUMNS
FROM [F_IntPrf].[F_IntPrf]
WHERE
(
[Jan]
,[ALL_TERRITORY]
);
Do they match? If they do then slowly add in the other dimensions until they don't match and then you know where the problem is

Mdx request get the first element of a tuple with datetime

My MDX request gives to me this result:
For my entities, I've multiple years for one value, I need just get the first year for the entity (and others dimensions). I've tried to use the function .FirstChild in the year dimension this return only value with the year '2014' (first year in my dimension). The function .Item() returns only empty values:
SELECT
NON EMPTY
{[Measures].[Value]} ON COLUMNS
,NON EMPTY
{
[EntiteFederal].[EntiteCode].[EntiteCode].ALLMEMBERS*
[T].[Year].[Year].ALLMEMBERS*
[T].[YearDate].[YearDate].ALLMEMBERS
}
DIMENSION PROPERTIES
MEMBER_CAPTION
,MEMBER_UNIQUE_NAME
ON ROWS
FROM [Mycube];
Hopefully this is working - tricky for me to test:
WITH
SET [EntYr] AS
Generate
(
[EntiteFederal].[EntiteCode].[EntiteCode].MEMBERS AS X
,
X.CurrentMember
*
Head
(
NonEmpty
(
[T].[Year].[Year].ALLMEMBERS * [T].[YearDate].[YearDate].ALLMEMBERS
,X.CurrentMember
)
)
)
SELECT
NON EMPTY
[Measures].[Value] ON COLUMNS
,NON EMPTY
[EntYr] ON ROWS
FROM [Mycube];

Filter dimensions for a specific member in MDX

I need to filter the dimension [Line] just for a specific [Year].Member.
For example,
[Time].[2004] to show results ([Product].[Line].[Classic Cars] and [Product].[Line].[Ships]) - excude the rest of [Product].[Line] members for [Time].[2004] but do not exclude [Product].[Line] members for the other [Time].Members.
I need a code compatible with Mondrian.
Any suggestion?
SELECT
NON EMPTY {[Measures].[Sales]} ON COLUMNS,
NON EMPTY NonEmptyCrossJoin([Time].[Years].Members, [Product].[Line].Members) ON ROWS
FROM
[SteelWheelsSales]
Something like this should work:
SELECT
NON EMPTY
{[Measures].[Sales]} ON COLUMNS
,NON EMPTY
{
(
[Time].[2004]
,{
[Product].[Line].[Classic Cars]
,[Product].[Line].[Ships]
}
)
,NonEmptyCrossJoin
(
Except
(
[Time].[Years].MEMBERS
,[Time].[2004]
)
,[Product].[Line].MEMBERS
)
} ON ROWS
FROM [SteelWheelsSales];

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

Easiest way to programmatically generate MDX rowcount query?

Right now I'm dealing with a program that can generate and return SQL or MDX queries (depending on the source database of the queries). I'm working on adding a feature that counts all the rows returned by a given query.
Now, I have some small background with SQL, so I was able to parse table names and generate a rowcount. However, MDX is a completely new beast for me.
In SQL, I'm creating:
SELECT
COUNT(SUM)
AS ROWS
FROM
(
COUNT(*) AS COUNT FROM TABLE1
UNION ALL
COUNT(*) AS COUNT FROM TABLE2
UNION ALL
COUNT(*) AS COUNT FROM TABLE3
ETC...
)
Now, what I'm wondering is, how would I do something similar with MDX? I've done some reading on MDX, and from what I gathered the basic notation is
[Dimension].[Hierarchy].[Level]
Now with SQL, I parsed the table names out of a larger generated query and simply inserted them into a new programmatically generated query. What would I have to grab from a larger MDX query to generate my own rowcounting query and sending it off to run? A simpler example of the MDX I'm dealing with would be:
WITH
MEMBER [BUSINESS1].[XQE_RS_CM1] AS '([BUSINESS1].[COMPANY_H].[all])', SOLVE_ORDER = 8
MEMBER [BUSINESS2].[XQE_RS_CM0] AS '([BUSINESS2].[all])', SOLVE_ORDER = 4
SELECT
NON EMPTY {[BUSINESS2].[ALL_TIME_H].[CALENDAR_YEAR_L].MEMBERS AS [XQE_SA1] , HEAD({[BUSINESS2].[XQE_RS_CM0]}, COUNT(HEAD([XQE_SA1]), INCLUDEEMPTY))} DIMENSION PROPERTIES PARENT_LEVEL, PARENT_UNIQUE_NAME ON AXIS(0),
NON EMPTY {[BUSINESS1].[COMPANY_H].[COMPANY_CD__L].MEMBERS AS [XQE_SA0] , HEAD({[BUSINESS1].[XQE_RS_CM1]}, COUNT(HEAD([XQE_SA0]), INCLUDEEMPTY))} DIMENSION PROPERTIES PARENT_LEVEL, PARENT_UNIQUE_NAME ON AXIS(1),
NON EMPTY {[Measures].[Measures].[BUSINESS3]} DIMENSION PROPERTIES PARENT_LEVEL, PARENT_UNIQUE_NAME ON AXIS(2)
FROM
[SOURCE] CELL PROPERTIES CELL_ORDINAL, FORMAT_STRING, VALUE
Any insight would be awesome, thanks.
At first glance your script looks reasonable then after unravelling it becomes a bit(!) more complex.
The main difference between this and other scripts is its use of axis(2). In a sub-select extra dimensions are often used but this is a little odd as most clients can't handle 3 dimensional cellsets - so I'm intrigued by what is consuming this info?
Also the member [BUSINESS1].[XQE_RS_CM1] is a single member as is [BUSINESS2].[XQE_RS_CM0] so what is the point of the sections HEAD... ?
WITH
MEMBER [BUSINESS1].[XQE_RS_CM1] AS
([BUSINESS1].[COMPANY_H].[all]), SOLVE_ORDER = 8
MEMBER [BUSINESS2].[XQE_RS_CM0] AS
([BUSINESS2].[all]), SOLVE_ORDER = 4
SELECT
NON EMPTY
{[BUSINESS2].[ALL_TIME_H].[CALENDAR_YEAR_L].MEMBERS AS [XQE_SA1]
,HEAD(
{[BUSINESS2].[XQE_RS_CM0]},
COUNT(
HEAD([XQE_SA1])
,INCLUDEEMPTY
)
)}
ON AXIS(0),
NON EMPTY
{[BUSINESS1].[COMPANY_H].[COMPANY_CD__L].MEMBERS AS [XQE_SA0]
,HEAD(
{[BUSINESS1].[XQE_RS_CM1]},
COUNT(
HEAD([XQE_SA0])
,INCLUDEEMPTY
)
)}
ON AXIS(1),
NON EMPTY
{
[Measures].[Measures].[BUSINESS3]
}
ON AXIS(2)
FROM
[SOURCE]
Does the following return the same data as the original script?
SELECT
NON EMPTY
{
[BUSINESS2].[ALL_TIME_H].[CALENDAR_YEAR_L].MEMBERS
,[BUSINESS2].[all]
}
ON 0,
NON EMPTY
{
[BUSINESS1].[COMPANY_H].[COMPANY_CD__L].MEMBERS
,[BUSINESS1].[COMPANY_H].[all]
}
ON 1
FROM [SOURCE]
WHERE [Measures].[Measures].[BUSINESS3];
All you need to calculate then is the count of members returned in the following set on the rows:
{
[BUSINESS1].[COMPANY_H].[COMPANY_CD__L].MEMBERS
,[BUSINESS1].[COMPANY_H].[all]
}