MDX - Only return chosen hierarchy level - mdx

I have an MDX Query in which I ask to get the 3rd level within a given hierarchy. When I am querying in MS SQL Server Managemnt Studio, I only get the selected hierarchy. However, when I run the query in an Excel table, I get all three levels.
What I ask for:
1st level
2nd level
3rd level <--- I only ask to recieve this guy.
What I get in Excel table:
1st level <--- returned
2nd level <--- returned
3rd level <--- returned
What I get in SQL Management studio table:
1st level
2nd level
3rd level <--- returned
So my question is:
1) Can I specify exactly what level I want to retrieve in the Excel table?
2) Can I retrieve all three levels in MS SQL Server Management Studio if I wanted to?
Overall I am interested in being able to control what is retrieved, of course :)
Thanks guys!!

See here for how to hide level 1-2 in Excel:
use ssas date hierarchy in excel pivottable
How are you running your query in SSMS. Cube browser? MDX query? If you wrote the query then what query did you try?

Related

Sum-up and then calculate vs. calculate and then sum-up (SSAS-MDX)

I have a cube in SSAS multidimensional mode.
I have created a calculating measure in visual studio called "Total Cost". The formula is:
[Measures].[Unit Cost]*[Measures].[Qty]
It is in the lowest level of granularity (i.e. - the transnational level information has these fields).
The formula works well, as long as I present the data in this same level of granularity (for example, when I create a pivot and the rows are transaction IDs - like the source file)
However, when I present it in an aggregate format (for example - by customer) - then instead of making the calculation and then sum it up, it sum up and then calculate.
Here is what I expected:
Expected results vs. What I get
My understanding, that this is regardless a (correct/incorrect) hierarchy structure. In other words, I expected this calculation to work even without defining any hierarchy between the transaction ID level and the customer level.
I'd appreciate your help!
In your SSAS project ->datasource view, you need to add a named calculation. This would be "[Unit Cost]*[Qty]". Now add this named calculation as a Measure in your Cube. This do the job. This problem was already addressed in the following link.
https://stackoverflow.com/questions/53554284/how-to-multiply-two-measures-prior-to-aggregation/53558733#53558733

How to use MDX query to specify date range

I'm recently trying out using MDX query in Power BI to query information directly from SAP Business warehouse cube. I encountered an error message that I can't figure out how to solve. The error message is: "SAP Business Warehouse: Specify a value for variable Day Interval"
In the report, choosing date range is mandatory. If I click through using Power BI to SAP BW connector, one of the steps is like the screenshot below:
The day is in the Cube called [0CALDAY] and is specified using [0CALDAY].[20101107]
However if I use MDX to query similar data using the code below
select {[Measures].[00O2THVIBBMJV8JIFLLW439K8]} on columns
from [0PT_MP01/Y_PT_TM_Q001_BOBJ]
where {[0CALDAY].[20101101]: [0CALDAY].[20101110]}
and click OK, I will receive the message says: "SAP Business Warehouse: Specify a value for variable Day Interval". My understanding of this is the way I'm choosing day interval is not recognized?
I've also tried to use & in front of [20101101] to make something like this: [0CALDAY].&[20101101] (according to some of the introduction online), then I receive syntax error message.
Is there anything I can do with the query language? Do I need to convert the number into date type? I'm really new to MDX and Cube, any suggestions will be really appreciated.
Thanks
You are required to add an SAP Variable at the end of the query.
To do this you can add an SAP Variable the following way:
SAP VARIABLES [<technical name of variable>] INCLUDING <value for variable>
Your query would end up looking like this:
select
{
[Measures].[00O2THVIBBMJV8JIFLLW439K8]
} on columns
from
[0PT_MP01/Y_PT_TM_Q001_BOBJ]
sap variables
[0CALDAY] including "20101101":"20101110"
Please find more information here:
https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=356124639
https://blogs.sap.com/2005/06/08/quick-help-in-creating-mdx-statement/
I would give an example to help explain the usage of mandatory SAP variables:
SELECT { [Measures].[measure1_name], [Measures].[measure2_name] } ON COLUMNS, NON EMPTY { [dimension1_name].[LEVEL01].MEMBERS, [dimension2_name].[LEVEL01].MEMBERS } ON ROWS FROM [BExQuery_name] SAP VARIABLES [!V000001] INCLUDING [dimension1_name].[80000000103] [!V000004] INCLUDING [0CALDAY].[20130101]:[0CALDAY].[20130104]
!V000001 and !V000004 are BEx variables.
The 80000000103 is a sample value for "dimension1_name". The 20130101 and 20130104 are sample range for 0CALDAY.

SSAS MDX Except statement issue

I am working on an requirement in Cube MDX like data for year 2008 and prior should not be displayed in report.
So thought of using MDX 'EXCEPT' function in SCOPE statement to exclude the mentioned years.
Time dimension is hierarchy with structure Year-->Quarter-->Month
Initial code was like
SCOPE([Measure Item].[Measure Item].&[SAL]);
SCOPE(EXCEPT({[Time].[Time].[Year]},{[Time].[Time].&[2006],[Time].[Time].&[2007],[Time].[Time].&[2008]}));
this=([Measure Item].[Measure Item].&[SAL]);
END SCOPE;
END SCOPE;
With the code after deploying, data for year 2008 and prior got excluded. But the issue here is, I can only see data on Grand Total on each Year. Please see the example in below screenshot, I cannot see data on Quarter level and month level.
Not able to see data on quarter and month level
Tried few other codes with descendants function, which is working in SSMS but when write it with SCOPE statements its not working.
Code written in SSMS:
select [Measures].[Value] on 0,
EXCEPT({[Time].[Time].members} ,
{descendants([Time].[Time].&[2006],0,SELF_AND_AFTER),descendants([Time].[Time].&[2007],0,SELF_AND_AFTER)}) on 1 from [TOPAS Reporting]
Working in SSMS but not working in SCOPE statement
I can see data on even Quarter and month level. But same code is not working in SCOPE statements of cube MDX.
Please help me to solve this issue and let me know for further details .
Thanks in advance.
Do you really need a scope statement?
You can achieve it by using the following calculation:
Aggregate(
existing [Time].[Time].&[20090101]:NULL,
[Measure Item].&[SAL]
)
where [Time].[Time].&[20090101] is the first day on the Day level.

Business Objects (webi) stuck forever on retrieving data for specific dates

I am very new to BO webintelligence.
I am doing a very simple query, retrieve Sales Amount for dates between 2012 and 2013. Just for this simple query when I run it, my BO crashes or gets stuck on "please wait" window. Why is this happening? If I select like 3 or 4 days like between Jan 1st 2012 and Jan 4th 2012, it runs fine. Is there anything from my end that I am doing wrong? This is in production mode.
I also wanted to point out that I have tried limiting my data set for specific region etc.
Too many unknowns to successfully assist. I presume this is webi 3.1.x or 4.1.x and I presume that the Sales Amount is a measure and that your query includes a date which does not include a time component. If you only have these two objects in your results pane and have the region in your conditions then pulling something like [Date] and sum([Sales Amt]) should not take long to execute. As previous poster suggests, try to execute the sql in a tool like SQL*Developer or Management Studio or however the source database / OLAP is stored.
Even though you've limited the data to a "region" this may be too much data. Try selecting a smaller result set of 100 rows or changing the option for "retrieve duplicate rows" on the query panel.
If possible, post the query from your report using generic object names?

Sql Server Analysis Services 2008 Totals

I am using Sql Server Analysis Services 2008 to build a cube. I have the following scenario and was wondering if anyone had any ideas on how to accomplish it. The cube is displayed over the web using a third party tool(Active Analysis). There is role based security so the user only see's their data. I am trying to allow the user to see their data, and also a total of all the other data. For example, the user currently only has access to see the total population of Massachusetts, but should also see a row below it with the total population of all states.
Year
States 2009 2010 2011
MA 1,000,000.00 1,050,000.00 1,102,500.00
All States(?) 365,000,000.00 383,250,000.00 402,412,500.00
You can edit the role and on the Dimension Data tab, you probably have Enable Visual Totals selected which prevents the user from seeing the total of all states. When you clear the checkbox, the user still sees only MA but the total should be all states.
complementing Stacia's answer because it may be tricky to understand:
Visual Totals = true -> see only the totals permitted to the user
Visual Totals = false -> see the big total even though it may
restricted some part because of permissions