I don't know ABCDs of MDX. I have this query that was handed over to me by my predecessor and that it is needed only once in a year! That time of the year happens to be now! The query runs and returns the results. However, I am unable to copy the result along with the rows and column names from the SSAS result window.
Googling I found the options of Linked servers, setting query options to save the result as csv etc, using SSIS packages and PowerPivot.
The first two are not possible because of restrictions on the DB. I need to go over a bunch of corporate hurdles to get the necessary permissions.
SSIS packages and Power Pivot - have the same issue. 'BUD' is a named set and it is referenced in the filter below in select statement. Both SSIS (when typed in OLEDB Source) throws error - The dimension [BUD] was not found.
Working with PowerPivot, I executed set create statement separately and then pasted only the code after 'WITH'. The Error was -The dimension [BUD] was not found.
Any help of how to reference the BUD in the select statement for Power Pivot or SSIS? I am using sqlsever2008r2.
This the procedure -
create set [DB1].BUD AS
nonemptycrossjoin(
{[Market].[Markets].&[Europe].children,[Market].[Markets].[Part of World].&[Africa].children},
[Product].[PL].&[CD] : [Product].[PL].&[KZ],
[Plant].[Plant].children
) go
with
member measures.callsCY1 as
/* Lot of measure calutaions here */
select
non empty
{
[Measures].[Qty Sold],
callsCY1,costCY1,MTRLcostCY1,LabourCostCY1,
SCR_C,callsRY1,costRY1,MTRLcostRY1,LabourCostRY1,
callsCY2,costCY2,MTRLcostCY2,LabourCostCY2,
callsRY2,costRY2,MTRLcostRY2,LabourCostRY2,
callsCY3,costCY3,MTRLcostCY3,LabourCostCY3,
callsRY3,costRY3,MTRLcostRY3,LabourCostRY3
}
*
{[Report Period].[Report Periods].[Quarter].&[2013-01-01T00:00:00] : [Report Period].[Report Periods].[Quarter].&[2014-06-01T00:00:00]}
on 0,
non empty
filter(
bud, [Measures].[Qty Sold] <> 0 OR [Measures].[QTY Service Calls] <> 0)
on 1
from [db1]
Does bud need to be seperate? Can't you just use this?
with
set [BUD] AS
nonemptycrossjoin(
{[Market].[Markets].&[Europe].children,[Market].[Markets].[Part of World].&[Africa].children},
[Product].[PL].&[CD] : [Product].[PL].&[KZ],
[Plant].[Plant].children
)
member measures.callsCY1 as
/* Lot of measure calutaions here */
select
non empty
{
[Measures].[Qty Sold],
callsCY1,costCY1,MTRLcostCY1,LabourCostCY1,
SCR_C,callsRY1,costRY1,MTRLcostRY1,LabourCostRY1,
callsCY2,costCY2,MTRLcostCY2,LabourCostCY2,
callsRY2,costRY2,MTRLcostRY2,LabourCostRY2,
callsCY3,costCY3,MTRLcostCY3,LabourCostCY3,
callsRY3,costRY3,MTRLcostRY3,LabourCostRY3
}
*
{[Report Period].[Report Periods].[Quarter].&[2013-01-01T00:00:00] : [Report Period].[Report Periods].[Quarter].&[2014-06-01T00:00:00]}
on 0,
non empty
filter(
bud, [Measures].[Qty Sold] <> 0 OR [Measures].[QTY Service Calls] <> 0)
on 1
from [db1]
Related
I have a dynamically Stored Procedure, which create a mdx statement for a OpenRowset Query. So it can happen that the objects from the mdx statement are empty. In this case I want back an empty string
SQL Server gives me this error:
"The OLE DB provider "" for linked server "(null)" indicates that either the object has no columns or the current user does not have permissions on that object."
I tried different things (Catch Statement, sp_describe_first_result_set) but nothing was working...
How can I handle this error ? In my statement below ie. the customer 'Abbas' is not available...
SELECT A.* FROM OpenRowset('MSOLAP', 'DATASOURCE=.; Initial Catalog=CUBE','
SELECT
{[Dim Customer].[v Dim Customer Name].[Customer].&[Abbas]} *
{[Dim Salesperson].[Lastname].&[Fima 1]} *
{[Dim Creditcard].[v Dim Creditcard Cardtype].[Cardtype].&[Vista]} ON 0
FROM CUBE
WHERE [Measures].[total]
') as A
Please try putting measures on columns and dimensions on rows:
SELECT A.* FROM OpenRowset('MSOLAP', 'DATASOURCE=.; Initial Catalog=CUBE','
SELECT {[Measures].[total]} ON 0,
{[Dim Customer].[v Dim Customer Name].[Customer].&[Abbas]} *
{[Dim Salesperson].[Lastname].&[Fima 1]} *
{[Dim Creditcard].[v Dim Creditcard Cardtype].[Cardtype].&[Vista]} ON 1
FROM CUBE
') as A
SELECT
NON EMPTY
{[Measures].[AMOUNTCUR]} ON 0
,NON EMPTY
{
NULL : [PRX_UE_DATE].[Calender].[Year].&[2015]
,[PRX_UE_DATE].[Calender].[Year].&[2017]
,Descendants
(
[PRX_UE_DATE].[Calender].[Year].&[2016]
,[PRX_UE_DATE].[Calender].[Month]
)
} ON 1
FROM [PRX_SalesDataModel];
I have a query like above. It's working It returns 2016 on month based others years are year based.
Now I have to add more dimensions on this mdx but when i try it to like
SELECT
NON EMPTY
{[Measures].[AMOUNTCUR]} ON 0
,NON EMPTY
{
NULL : [PRX_UE_DATE].[Calender].[Year].&[2015]
,[PRX_UE_DATE].[Calender].[Year].&[2017]
,
Descendants
(
[PRX_UE_DATE].[Calender].[Year].&[2016]
,[PRX_UE_DATE].[Calender].[Month]
)
*
[PRX UE CLIENT].[SEGMENTID].ALLMEMBERS
} ON 1
FROM [PRX_SalesDataModel];
I get error Members, tuples or sets must use the same hierarchies in the function.
You just need to keep all the date dimension stuff in set braces {...}:
SELECT
NON EMPTY
{[Measures].[AMOUNTCUR]} ON 0
,NON EMPTY
{
NULL : [PRX_UE_DATE].[Calender].[Year].&[2015]
,[PRX_UE_DATE].[Calender].[Year].&[2017]
,
Descendants
(
[PRX_UE_DATE].[Calender].[Year].&[2016]
,[PRX_UE_DATE].[Calender].[Month]
)
}
* [PRX UE CLIENT].[SEGMENTID].ALLMEMBERS
ON 1
FROM [PRX_SalesDataModel];
You could even make it maybe more readable by moving the date stuff into a named set via a WITH clause:
WITH SET [DatesSet] AS
{
NULL : [PRX_UE_DATE].[Calender].[Year].&[2015]
,[PRX_UE_DATE].[Calender].[Year].&[2017]
,
Descendants
(
[PRX_UE_DATE].[Calender].[Year].&[2016]
,[PRX_UE_DATE].[Calender].[Month]
)
}
SELECT
NON EMPTY
{[Measures].[AMOUNTCUR]} ON 0
,NON EMPTY
[DatesSet]
* [PRX UE CLIENT].[SEGMENTID].ALLMEMBERS
ON 1
FROM [PRX_SalesDataModel];
You've got your answer from #whytheq on why the error cropped up. There is just one part which I felt is not handled yet. You are building the set of years by hand. Instead of that, it can be made dynamic like below -
with set AllYearsExceptCurrent as
filter(
[PRX_UE_DATE].[Calender].[Year].members as yr,
yr.current.item(0).member_value <> Format(Now(), "yyyy")
)
i have a MDX query in Mondrian like below
with member [Measures].[a] as '([Measures].[LCount] * 2)'
member [Measures].[b] as '([Measures].[a] * 3)'
select {[Rate].[Rate].Members} ON COLUMNS,
{[Measures].[a], [Measures].[b]} ON ROWS
from [c];
and i want to set caption for my calculated measures that is different with their uniqeName
what should i do?
NOTICE :
with member [Measures].[a] as '([Measures].[LCount] * 2)',
CAPTION = "my measure"
doesn't work!
I tried a statement similar to
with member [Measures].[a] as '([Measures].[Internet Sales Amount] * 2)', Caption = 'my measure'
member [Measures].[b] as '([Measures].[a] * 3)'
select {[Customer].[Customer Geography].[Country].members} ON COLUMNS,
{[Measures].[a], [Measures].[b]} ON ROWS
from [Adventure Works];
and it worked without problems. Note: I used single quotes for the caption text.
Just a remark unrelated to this: You can omit the quotes around the member definition if you do not need compatibility with Analysis Services in the 2000 version. This sometimes (but not in this case) gives you better syntax error messages.
First of all I use the SQL Management Studio for this query (no Excel 2007 that seems to have problems):
WITH
SET [Project period dates] AS
{
StrToMember("[Time].[Date].&[" + [Project].[ParentProject].CURRENTMEMBER.PROPERTIES("Project Start Iso") + "]"):
StrToMember("[Time].[Date].&[" + [Project].[ParentProject].CURRENTMEMBER.PROPERTIES("Project End Iso") + "]")
}
MEMBER [Measures].[Test] AS ([Project period dates].COUNT)
SELECT
{
[Measures].[Test]
}
on 0,
NONEMPTY ([Project].[ParentProject].MEMBERS)
DIMENSION PROPERTIES [Project].[ParentProject].[Project Duration], [Project].[ParentProject].[Project Start Iso], [Project].[ParentProject].[Project End Iso]
on 1
FROM
[MyCube]
WHERE
(
[Orgunit].[Orgunit].&[448]
)
This query delivers a list of projects with its three properties and a calculated member that is based upon my calculated set. The properties show the right values, but the calculated member shows always the same: the result of the very first project it should be calculated for.
I don't really understand why, because MSDN says:
The current member changes on a hierarchy used on an axis in a query.
Therefore, the current member on other hierarchies on the same
dimension that are not used on an axis can also change; this behavior
is called 'auto-exists'.
They give examples with calculated members, but I think that should also work with calculated sets, I have read that query-based calculated sets are dynamic by nature. Maybe somebody can tell me if I understood that wrong or what else is my problem here.
The named set are only computed once within a query. That is why your calculated member always return the same value.
You just have to remove the named set from your query:
MEMBER [Measures].[Test] AS {
StrToMember("[Time].[Date].&[" + [Project].[ParentProject].CURRENTMEMBER.PROPERTIES("Project Start Iso") + "]"):
StrToMember("[Time].[Date].&[" + [Project].[ParentProject].CURRENTMEMBER.PROPERTIES("Project End Iso") + "]")
}.COUNT
I m trying to run a sql in access 2007 which gives the error
"you tried to execute a query that does not include the specified expression 'round(volumePass/Volume*100,2)' as part of an aggregate function".
Whereas i have mentioned it in the sql statement
group by round(volumePass/Volume*100,2)
SELECT s.[sub process name], Round(Avg(s.[TollGate FTEs]),2) AS TollGateFTEs,
Sum(w.volume) AS Volume,
Sum(Switch(w.TAT='Pass',w.Volume,w.TAT='Fail',0)) AS VolumePass,
Sum(IIf(w.[combined accuracy]='PASS',1,0)) AS AccuracyPass,
Sum(IIf(w.[combined accuracy]='',0,1)) AS TotalAccuracy,
Round((VolumePass/Volume)*100,2) AS TATPercentage,
Round((AccuracyPass/TotalAccuracy)*100,2) AS AccuracyPercentage,
Format(w.[reporting month],'mmm-yy') AS [Rep Month] FROM Work_Log1 AS w,
[sub process] AS s WHERE w.[sub process] In (SELECT s.[sub_process_id] FROM
[Sub Process] s,
[process mapping] m where m.[process name] like 'Accounting Control%'
and s.[mapped to process id] = m.[mapping id]) And w.[sub process]=[s].[sub_process_id]
AND (w.[Activity_start_date] Between #06/01/2012# And #06/15/2012#)
AND ([w].[sla applicable]=1 Or 0 Or '') and
(w.[status] Like 'Complete%') group BY Format(w.[reporting month],'mmm-yy'),
s.[sub process name], (Round((VolumePass/Volume)*100,2));
Where is that it is not able to pick up correctly.
giving the alias "TATPercentage" still not works and gives the same error.
This query works well in access query designer but cannot be run with sql inside vba.
Update:
Got it to run using the dao engine in vba.. no luck with adodb engine
Round((VolumePass/Volume)*100,2) AS TATPercentage
^^^^^^^^^^ ^^^^^^
round() is not an aggregate function. You'll have to group on those fields as well (volumepass and volume), and you'll run into the same error with your next two lines with accuracypass, acuracytotal, reporting month, etc...