MDX Query for Top 10 in SSAS Project
Hi Guys,
Please I need an MDX query that will help me calculate Top 10 inside the SSAS project.
Your help will be greatly appreciated.
Thanks
me
Hi,
I know nothing about PowerView and PerformancePoint Server but I played with Excel and I am able to use the named set I created. Here are the steps which I followed.
1 - Create the named set. Remember... this name set appears inside the dimension which you use as the first parameter inside TOPCOUNT function.
2 - Deploy the cube and perform a process full.
3 - Navigate to PowerPivot ribbon and click on PowerPivot Window.
4 - Choose From Database > From Analysis Services or PowerPivot. Specify the necessary SSAS server credentials and connect to the Cube which you are interested.
When it comes to the MDX query design window you construct your MDX code in SSMS and copy that code. You also can use the design mode as well. In this case you have to toggle the "design mode" option and enter to manual mode which you can type
your MDX code. Here is a screenshot of that.
5 - Validate your query and click Finish. Once the data is in you can create your power pivot report. Here is an example.
I hope this helps to troubleshoot your issue.
Best regards...
Chandima Lakmal Fonseka
Similar Messages
-
Oracle query for top two salary of each group departmentwise
oracle query for top two salary departmentwise
sigh...
But anyway,
Top-n queries:
http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2853107469873
and ofcourse lots of 'em here on OTN... -
SQL Query for TOP 10 Average CPU
Have a SCOM Report request for a line graph showing top 10 average CPU for a group of servers. I have a query that will show all of the servers in a group for the last day, with the average CPU by hour. How can I extend the SQL query to only select the TOP
10 average CPU from the group? Here is the Query I have:
SELECT
vPerf.DateTime,
vPerf.SampleCount,
cast(vPerf.AverageValue as numeric(10,2)) as AverageCPU,
vPerformanceRuleInstance.InstanceName,
vManagedEntity.Path,
vPerformanceRule.ObjectName,
vPerformanceRule.CounterName
FROM Perf.vPerfHourly AS vPerf INNER JOIN
vPerformanceRuleInstance ON vPerformanceRuleInstance.PerformanceRuleInstanceRowId = vPerf.PerformanceRuleInstanceRowId INNER JOIN
vManagedEntity ON vPerf.ManagedEntityRowId = vManagedEntity.ManagedEntityRowId INNER JOIN
vPerformanceRule ON vPerformanceRuleInstance.RuleRowId = vPerformanceRule.RuleRowId
WHERE
vPerf.DateTime >= DATEADD(Day, -1, GetDate())
AND vPerformanceRule.ObjectName like '%Processor Information%'
AND vPerformanceRuleInstance.InstanceName = '_Total'
AND (vPerformanceRule.CounterName IN ('% Processor Time'))
AND (vManagedEntity.Path IN (SELECT dbo.vManagedEntity.Name
FROM dbo.vManagedEntity INNER JOIN
dbo.vRelationship On dbo.vManagedEntity.ManagedEntityRowId = dbo.vRelationship.TargetManagedEntityRowId INNER JOIN
dbo.vManagedEntity As CompGroup On dbo.vRelationship.SourcemanagedEntityRowId = CompGroup.ManagedEntityRowId
WHERE CompGroup.DisplayName = 'bemis ibb prod'
ORDER BY path, vPerf.DateTime
Results
DateTime
SampleCount
AverageCPU
InstanceName
Path
ObjectName
CounterName
2/26/15 3:00 PM
2
1.98
_Total
servername.corp.com
Processor Information
% Processor Time
2/26/15 4:00 PM
2
2.09
_Total
servername.corp.com
Processor Information
% Processor Time
2/26/15 5:00 PM
2
1.72
_Total
servername.corp.com
Processor Information
% Processor Time
2/26/15 6:00 PM
2
1.83
_Total
servername.corp.com
Processor Information
% Processor Time
Thanks in Advance!
Mike HanlonHi
Sql Query
SELECT TOP 10
vPerf.DateTime,
vPerf.SampleCount,
cast(vPerf.AverageValue as numeric(10,2)) as AverageCPU,
vPerformanceRuleInstance.InstanceName,
vManagedEntity.Path,
vPerformanceRule.ObjectName,
vPerformanceRule.CounterName
FROM Perf.vPerfHourly AS vPerf INNER JOIN
vPerformanceRuleInstance ON vPerformanceRuleInstance.PerformanceRuleInstanceRowId = vPerf.PerformanceRuleInstanceRowId
INNER JOIN
vManagedEntity ON vPerf.ManagedEntityRowId = vManagedEntity.ManagedEntityRowId INNER JOIN
vPerformanceRule ON vPerformanceRuleInstance.RuleRowId = vPerformanceRule.RuleRowId
WHERE
vPerf.DateTime >= DATEADD(Day, -1, GetDate())
AND vPerformanceRule.ObjectName like '%Processor Information%'
AND vPerformanceRuleInstance.InstanceName = '_Total'
AND (vPerformanceRule.CounterName IN ('% Processor Time'))
AND (vManagedEntity.Path IN (SELECT dbo.vManagedEntity.Name
FROM dbo.vManagedEntity INNER JOIN
dbo.vRelationship On dbo.vManagedEntity.ManagedEntityRowId = dbo.vRelationship.TargetManagedEntityRowId INNER
JOIN
dbo.vManagedEntity As CompGroup On dbo.vRelationship.SourcemanagedEntityRowId = CompGroup.ManagedEntityRowId
WHERE CompGroup.DisplayName = 'bemis ibb prod'
ORDER BY path, vPerf.DateTime
Regards
sridhar v -
MDX query for parent-child combination display
Hi guys..
I am really new to the Essbase technology.
Could you please help me out with this one:
is it possible to extract the data(for example the metadata of a outline)..eg:-
The outline structure is as follows :
A1
A11
A12
A2
A21
A22
I want a MDX query to display it as :
A1 A11
A1 A12
A2 A21
A2 A22
I have tried various ways but couldnt come up with a query for this.
Thanks in advance for all your help.Unfortunately MDX cannot do this. If you think about what you are asking for, you are essentially saying that you want to see members of the same dimension on different axis. Multi-dimensional queries can't do that (think about trying to do it with addin).
A further limiation is that MDX is not robust enough to allow you to work the results into a single axis using a concatenation function because while there is a string-to-member function, there is no member-to-string function and concat requires a string as input.
Other approaches would require MDX to support joins or subqueries, which it does not.
As others have mentioned, to do what you want to do, you need outline extractor or something like that.
*Fun fact - if you have OBIEE 11g, it can do reporting in Essbase with hierarchy members in hierarchy format or column format, which will give you the results you need. That alone is good reason to start using OBIEE. -
Missing field for MDX query for All Members
Hello,
I'm using MDX query with SSRS for report and I ran into this issue:
Query 1:
select non empty ([Product].[Category].allmembers*[Date].[Calendar].[Calendar Year].allmembers ) on 1,
([Measures].[Internet Sales Amount]) on 0
from [Adventure Works]
go
Query 2
select non empty ([Product].[Category].[All]*[Date].[Calendar].[Calendar Year].allmembers ) on 1,
([Measures].[Internet Sales Amount]) on 0
from [Adventure Works]
In case I run query 2 in SSDT (query designer), it doesn't return first column whereas if I run above two queries in SSMS, I get similar columns/fields.
How it can be resolved in SSRS to return all columns for query 1 and 2.
Thanks,
P
mark it as answer if it answered your question :)Hello,
I'm using MDX query with SSRS for report and I ran into this issue:
Query 1:
select non empty ([Product].[Category].allmembers*[Date].[Calendar].[Calendar Year].allmembers ) on 1,
([Measures].[Internet Sales Amount]) on 0
from [Adventure Works]
go
Query 2
select non empty ([Product].[Category].[All]*[Date].[Calendar].[Calendar Year].allmembers ) on 1,
([Measures].[Internet Sales Amount]) on 0
from [Adventure Works]
In case I run query 2 in SSDT (query designer), it doesn't return first column whereas if I run above two queries in SSMS, I get similar columns/fields.
How it can be resolved in SSRS to return all columns for query 1 and 2.
Thanks,
P -
Standard Query for Top 10 queries and Users
Hi Experts,
Is there any query which gives the details like ,
1. Top 10 queries executed in a month
2. Top 10 users ( By no of queries executed )
Regards,
Bhadri M.1. Top 10 queries executed in a month
Use Query 0TCT_MCA1_Q0142.
In this report you will have to filter variable BI Object to Queries and also it gives stats for the last 30 days, you have have to remove the SAP User exit variable in case you do not want to use the 30 days option. And then you will have to define Condition for Top 10.
2. Top 10 users ( By no of queries executed )
Use Query 0TCT_MCA1_Q0141.
Similarly you have to modify this query.
-Neelesh -
MDX query for to get the data from two cubes
Hi
Can you tell me how to create MDX query to get the values from two cubes. (One hierarchy from first cube and one hierarchy from second cube)
Can you give me one example.
Regards,
Madhu.
SudhanHi Sudhan,
According to your description, you want to retrieve data from two different cubes, right? The short answer is yes. To query multiple cubes from a single MDX statement use the LOOKUPCUBE function (you can't specify multiple cubes in your FROM statement).
The LOOKUPCUBE function will only work on cubes that utilize the same source database as the cube on which the MDX statement is running. For the detail information about it, please refer to the link below to see the blog.
Retrieving Data From Multiple Cubes in an MDX Query Using the Lookupcube Function
Regards,
Charlie Liao
TechNet Community Support -
Query for top 10 selling products and their current stock
Hi ppl
I am using the sales overview cube 0SD_C03 to get top 10 selling products. What I want is to get the current stock available of the top 10 products from Material Stocks/Movements cube 0IC_C03. From what I know, we have to make a multiprovider to get this information. Can anyone guide me how to go about it?Hello Javed,
You can use Replacement path for this.
1.Create a report for Top 10 Products in InfoCube 0SD_C03 - Exampls Report A
2.Create another report with Stock and use a variable for Product with processing type replacement path in InfoCube0IC_C03 - Example Report B
3. In Report B and assing the Report A to this variable.
When you execute the Report B it will execute the Report A in background and displays it in Report B.
Hope it helps,
thanks
Chandran -
Hi All,
Looking for a query that would return the top 5 sales items along with sales values, between a date range
Thanks
Ranjit KrishnanHi,
You may try this if Credit Memos do not need to be included:
SELECT TOP 5 T1.ItemCode, MAX(T1.Dscription) as 'Item Description', SUM(T1.LineTotal) as 'Amount(LC)'
FROM dbo.OINV T0
INNER JOIN dbo.INV1 T1 ON T1.DocENtry = T0.DocENtry
WHERE t0.docdate >= [%0\] and t0.docdate <= [%1\] AND t0.doctype = 'I'
GROUP BY T1.ItemCode
Order by SUM(T1.LineTotal) DESC
Thanks,
Gordon -
How to build MDX query for two periods of time?
I have the following MDX:
SELECT NON EMPTY
[Measures].[Returns],
[Measures].[Returns]
ON COLUMNS,
NON EMPTY
([Employees].[Company].[Company].ALLMEMBERS )
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM
SELECT
STRTOSET("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]", CONSTRAINED)
) ON COLUMNS FROM [cbSales]
WHERE
IIF(
STRTOSET("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]", CONSTRAINED).Count = 1,
STRTOSET("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]", CONSTRAINED),
[Exec Date].[Hierarchy].currentmember
Both columns shows returned data for month 2014/01
I want to have data for the next month (2014/02) in the second column.
How can I change the query to achieve my goal.Hi,
To achieve this you need to create another measure with the help of ParallelPeriod function. Check the following example;
WITH MEMBER [Measures].[Sales Amount Current] AS [Measures].[Sales Amount]
MEMBER [Measures].[Sales Amount Next] AS ([Measures].[Sales Amount], PARALLELPERIOD([Date].[Calendar].[Month],-1, [Date].[Calendar].CURRENTMEMBER)), format_string = "Currency"
MEMBER [Measures].[Current Month] AS [Date].[Calendar].CURRENTMEMBER.Member_Caption
MEMBER [Measures].[Next Month] AS PARALLELPERIOD([Date].[Calendar].[Month],-1, [Date].[Calendar].CURRENTMEMBER).Member_Caption
SELECT {[Measures].[Current Month], [Measures].[Sales Amount Current], [Measures].[Next Month], [Measures].[Sales Amount Next]} ON COLUMNS,
{[Product].[Category].[Category].MEMBERS} ON ROWS
FROM [Adventure Works]
WHERE [Date].[Calendar].[Month].&[2007]&[10]
For ParallelPeriod specify -1 for "Numeric Expression" to navigate forward of the date hierarchy.
Best regards,
Chandima
Thanks, nice answer -
MDX Query for Average customer first sale amount for each year
Hello,
I new to MDX, and I am looking to build a query that would get all the first sale amount for the customes and average that. The intent is to use find an average each year. I am looking to use this against the adventure works database.
I am not sure exatcly how to start this . Any help is much appreciated.
JHi,
I'll do it in several stages.
let's first define an ordered set of date/sale to one customer over all periods:
SELECT
{[Measures].[Internet Sales Amount]} ON 0
NonEmpty
[Date].[Calendar].[Date]
[Customer].[Customer].&[15561]
,[Measures].[Internet Sales Amount]
,[Customer].[Customter].&[15561]
) ON 1
FROM [Adventure Works];
we retain the first line of the result set with item(0):
SELECT
{[Measures].[Internet Sales Amount]} ON 0
NonEmpty
[Date].[Calendar].[Date]
[Customer].[Customer].&[15561]
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].&[15561]
).Item(0) ON 1
FROM [Adventure Works];
next, for each year we define a measure that will retain the first sale for each customer
(I limit the customer set to the first 2000)
WITH
MEMBER [Measures].[Mymeasure 2006] AS
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2006]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
MEMBER [Measures].[Mymeasure 2007] AS
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2007]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
SELECT
[Measures].[Mymeasure 2006]
,[Measures].[Mymeasure 2007]
} ON 0
,NON EMPTY
Head
[Customer].[Customer].[Customer]
,2000
) ON 1
FROM [Adventure Works];
We then take the average for each year:
WITH
MEMBER [Measures].[AVG cust first sale 2006] AS
Avg
Head
[Customer].[Customer].[Customer]
,2000
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2006]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
MEMBER [Measures].[AVG cust first sale 2007] AS
Avg
Head
[Customer].[Customer].[Customer]
,2000
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2007]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
SELECT
[Measures].[AVG cust first sale 2006]
,[Measures].[AVG cust first sale 2007]
} ON 0
FROM [Adventure Works];
Philip, -
MDX query for derived measures
Hi,
I have a requirement to show data like the below output. Could anyone suggest how do I proceed. For the below report StoreID and Date would be my parameters to the below report.
StoreID
date
Department
Total Sales For Dept A
Units Sold for Dept A
Total Sales
For All Dept
11002
21/05/2014
A
100
5
1000
11004
22/05/2014
A
150
3
1000
Thanks in advance.Hi ,
I hope I understand your request, Do you want to have a special calculation for a specific case ?
If so, you can add a member to your query to be evaluated on the members you want :
With member standard as ([Measures].[Sales],[Dept].[Dept].CurrentMember,[Date].[Date].CurrentMember ,,,)
member NonStandard as ([Measures].[Sales],[Dept].[Dept].[All],[Date].[Date].CurrentMember ,,,)
Regards, David . -
Need an MDX query for Date range
Hi there,
My requirement is to filter sales from 1st of month to until holiday of the month. I am able to use to ":" range function for filtering, but I am not able to filter on holiday date. Becuase both filter and exists are giving set results, I need
member expression to use range function. Please let me know ASAP.
Thanks,
ATRSAMSHi ATRSAMS ,
You can get the first member of the month with the OpeningPeriod function, and item(#) to have a specific member from a set .
So if you want first member from your set : filter(.....).ITEM(0)
Regards, David . -
Date parameters using MDX query
Hello experts,
Not sure if this question falls under SSAS or SSRS but I'm writing it here for now and hopefully get the answer.
I'm using SSAS cube to develop a report using SSRS and this is the first time I'm doing it. I want to filter records based on date range and did some research online. My report contains two datasets:
1. dsMain dataset -> it contains all the field which I want to use in the report and added a parameter thru query designed with following settings:
Dimension : Dates
Hierachary : Date
Operator : Range (Inclusive)
Parameters : checked
it created two parameters called FromDatesDate and toDatesDate
2. I created another dataset called dsDate and wrote a custom query (found at following link) and changed FromDatesDate and ToDatesDate using this date dataset
https://jsimonbi.wordpress.com/2011/03/22/using-a-date-parameter-in-ssrs-with-mdx/
Query for dsDate
WITH
MEMBER DateValue
AS
[Dates].[Date].CurrentMember.UniqueName
MEMBER DateLabel
AS
[Dates].[Date].CurrentMember.Name
SELECT
[Measures].[DateValue],
[Measures].[DateLabel]
} ON 0,
[Dates].[Date].[Date]
} ON 1
FROM [myCube]
Here is the value returned by dsDate dataset (above query)
DateValue DateLabel
06/04/1980 [Dates].[Date].&[29375]
06/04/1980
06/05/1980 [Dates].[Date].&[29376]
06/05/1980
06/06/1980 [Dates].[Date].&[29377]
06/06/1980
06/07/1980 [Dates].[Date].&[29378]
06/07/1980
06/08/1980 [Dates].[Date].&[29379]
06/08/1980
06/09/1980 [Dates].[Date].&[29380]
06/09/1980
06/10/1980 [Dates].[Date].&[29381]
06/10/1980
06/11/1980 [Dates].[Date].&[29382]
06/11/1980
06/12/1980 [Dates].[Date].&[29383]
06/12/1980
06/13/1980 [Dates].[Date].&[29384]
06/13/1980
Here is what I changed in FromDatesDate and ToDatesDate parmeter:
Under Available Values tab:
Dataset : dsDate
Value Field : DateValue
Label Field : DateLabel
Here are my questions:
1. I want to use date/time parameter so that user doesn't have to scroll thru whole date dimension.
2. I changed the FromDatesDate and ToDatesDate to date/time parameter, removed the values from Available values tab and made the following changes on Parmaeters expression under dsMain dataset
=”[Dates].[Date].&[” + Format(CDate(Parameters!FromDatesDate.Value),”MM/dd/yyyy”)
+ “T00:00:00]”
=”[Dates].[Date].&[” + Format(CDate(Parameters!ToDatesDate.Value),”MM/dd/yyyy”)
+ “T00:00:00]”
Now when I run the report I get following error:
Query (1, 55) The restrictions imposed by the CONSTRAINED flag in the STRTOMEMBER function are violated.
I think the reason is by changing parameter to date/time, now I cannot get "DateValue" which is required for the query.
1. What is the best way to work with date parameters?
Hope it is all clear and look forward to hear from experts.
Thanks,
P
mark it as answer if it answered your question :)Hi Parry2k,
In Analysis Services, a member can be referenced by either its member name or by its member key. The member key is used by the dimension to specifically identify a given member. The ampersand (&) character is used in MDX to differentiate
a member key from a member name. In this scenario, the datetime is member name, not the member key. So you should not add "&".
Reference:
Member Names and Keys
Simon Hou
TechNet Community Support -
ASO MDX query in outline??????
Trying to write a MDX query for the Account member
Hierarchy:
Account
A001
A002
A003
A008
Scenario
AG00
AG01
AG06
AG08
AG09
Organization
ETCE
E023
E024
E070
I need to caluculate for the Account AG08 the value should be derived from AG07 and for the same account AG08 for the Organization member "E070" the value should be same as AG09 ( i.e AG09 = AG08 )
I writen below query at the level "0" retrival query is good but when i use the Top level query "ETCE" parent level the value in "E070" is eliminating . Query writen below
NONEMPTYMEMBER [A001],[A007]
CASE
WHEN (IS([Organization].CurrentMember, [E070])) THEN
([A009])
WHEN (IS([Scenario].CurrentMember, [AG00])) THEN
(([A007] * -1)/100)
WHEN (IS([Scenario].CurrentMember, [AG01])) THEN
(([A007] * -1)/100)
WHEN (IS([Scenario].CurrentMember, [AG02])) THEN
(([A007] * -3)/100)
WHEN (IS([Scenario].CurrentMember, [AG03])) THEN
(([A007] * -10)/100)
WHEN (IS([Scenario].CurrentMember, [AG04])) THEN
(([A007] * -20)/100)
WHEN (IS([Scenario].CurrentMember, [AG05])) THEN
(([A007] * -80)/100)
WHEN (IS([Scenario].CurrentMember, [AG06])) THEN
([A007])
ELSE
Missing
END
At Bottom level "0" results are coming as expected but Its not working at the top level Organization ETCE level Please help ????
Thanks
Venu
Edited by: user13351102 on Oct 28, 2011 5:19 PM
Edited by: user13351102 on Oct 28, 2011 6:31 PMGuru's any help on this ASO Member formula query ??
Maybe you are looking for
-
Not able to access DM Packages through BPF
Hi Friends I have created a Team name BPF and i have assigned the user. That user has following task for his task profile. The Task Profile is neither a SYSTEM, PRIMARY OR SECONDARY ADMIN TYPE. And the task that are being assinged are EXECUTE BPF EXE
-
Load Balancing with ALBPM 6.0
Hi - We have had some challenges with load balancing in WebLogic Server 9.2.2 with ALBPM 6.0. We have tried to set the Front End HTTP host and ports on the cluster and individual hosts with no luck. Anyone else have a similar problem?
-
Problem porting CS5.5 to CS6
Hello I run into a problem when I try to port a CS5.5 plugin to CS6. I get the following error message: >C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(108,5): error MSB3073: The command "merge_res.cmd "..\objR\ColormanLite\"
-
Prevent drive from mounting at startup
There is an archived message on this same subject that never received a reply. I perform my backups to a second internal drive and would like to prevent it from mounting at startup. Any ideas? To clarify: I can come up with many ways to UNmount a dri
-
Can't update Proxy preferences
I'm running Release 1.0 (Version 2005.05.20.10.51 of package SUNWupdatemgrr) on sparc, and I'm not able to change my password settings in the proxy authentications preferences. First I have installed the preview of the software (downloaded in June),