SSAS Rank with respect to multiple measure and dimension - ssas

I've a Rank column in my report.
The logic behind the rank column is based on a Measure value (either a count or sum) and based on three dimensions.
For example,
I've to show a rank based on a Measure value (Total customers) of a
selected Company(which will be parameter for the report, which in turn
a dimension) based on Period (It can be anything year, half-yearly,
quarterly, monthly) and a product group
.
Even the measure value can be chosen as a parameter from the report which makes things complex.
How can I accomplish this?
I think I can use RANK function of SSAS for a calculated field along with ORDER.
But can we create one RANK function without hard coding the measure or dimension?

I would handle this by creating a stored procedure to return the data for my report.
The stored procedure would use the report parameters to build an MDX string and execute it on the SSAS server with OPENQUERY(). The MDX would only have to get the measure that the report is to be ranked by on Columns, and then Period and Product Group on rows.
Execute the MDX in the stored procedure, storing the result in a temporary table, and then SELECT from the temporary table using either the ROW_NUMBER() or RANK() function to add the Rank column to the output.

Related

DAX Need Power Pivot Measure to be SUM of ALL Columns in Each Column. How to ignore column context

I have a Pivot Table with Salespeople as columns. I have income measures that correctly show (in the rows) the income each of them produced. However, I would like to show everyone's income in each column on some of the measures.
The reason is I want them to be paid on some income items (row measures) on the total of all salespeople not on their individual production.
Is there a way to make a measure ignore the column context?
DAX ALL
Try to use ALL function and give your column as a parameter.
It will clear currently applied filters.

SSAS 2012 TABULAR : Data load testing using MDX

I have a model developed in Tabular 2012. When I connect to the cube, I see FACT and DIMENSION tables listed.
I am not a developer - I am just asked to test the data load.
I just need to locate an example record from my source DB in FACT( Or Dimension ) table in the cube. I goggled it well, but could not find anything relevant as the the MDX queries I explored were always using some [Measure].blah blah to retrieve the data. Developer has defined just 1 measure in the DB. Is it possible to retrieve 1 row using MDX just like select 8 from table in SQL?
My problem is that even if I put one fact column on the columns axis and dimension key on row- axis, it just retrieves value 1.
I was under the impression that tabular did not have multi-demnsional cubes but has a "tabular model" as the underlying structure.
If you are using mdx and want several columns of data with just one measure then use CROSSJOIN:
SELECT
[Measures].[X] ON COLUMNS,
{CROSSJOIN (
[Dimension1].[someLevel].members
,[Dimension1].[someLevel].members
,[Dimension1].[someLevel].members
,[Dimension1].[someLevel].members) }
ON ROWS
FROM [cubeName]
Alternative syntax is:
SELECT
[Measures].[X] ON COLUMNS,
[Dimension1].[someLevel].members
*[Dimension2].[someLevel].members
*[Dimension3].[someLevel].members
*[Dimension4].[someLevel].members
ON ROWS
FROM [cubeName]

Need to group on expression in column in tablix

I have a report that is grouped on several fields from my dataset. However, one of the columns in my tablix is an expression, NOT a dataset field and I don't see that expression as an option to pick when I try to add it to the detail grouping.
basically, I'm pulling the vendor's name on each order. For one particular type of order (flower seed) one order can have several different vendors that actually supply the seed, but since it comes from us, WE really are the vendor. So, in the column for vendor name in my tablix, I have an expression: =IIF(Fields!major_grp.Value = "S","Seeds",Fields!vend_desc.Value) so that if it's a seed order, I make the vendor description "Seeds", otherwise I use whatever is the real value in the Field!vend_desc.value.
I need to be able to add new group expression on my calculated value, not the actual value from the dataset but it's not giving me my expression as an option to pick, just the dataset value "vend_desc". Is it possible to group on an expression in a column of a tablix?
the only other thing I thought might be possible is to calculate the value of the vendor description in my SQL select statement in the dataset that pulls the data initially, but the Select statement I'm using is EXTREMELY complex and I'd hate to make it even muddier....
You can create group on expression, in the group properties, where it says group on, add your expression there.
You can further look into the following links
http://technet.microsoft.com/en-us/library/dd220419.aspx
http://technet.microsoft.com/en-us/library/ms170712.aspx

combining multiple SSAS queries as one dataset

I have a fact-table with one date dimension linked three times to attributes for Ordered, Prepared and Shipped dates. So, I am able to get counts on ordering, manufacturing and dispatch and currently I am running these as three separate excel pivot table requests and combining them into one graphs giving three bars per month. I am wondering if there is a more sleek way I should be doing this by which I write a query which returns the three separate counts as individual measures rather than running the query three times doing it once against each dimension.
Currently, the fact table looks something like this: -
DEPID, PRODCODE, ORDERDATE, PROCESSDATE,SHIPDATE
001,001,20120101,20120102,20120104
002,001,20120103,20120105,20120106
003,002,20120104,20120106,20120107
004,002,20120105,20120107,20120108
You could create 3 calculated measures in the cube (Ordering Count, Manufacturing Count, Dispatch Count)...then just drag them into your pivot table in the values section and use a date dimension in the rows group.

Good MDX default query

I have build an MDX editor and now need a good default query which executes and already has two dimensions. I would like to place the measures on the first dimension (without knowing their names), and any other cube dimension on the second result dimension. Currently I have achived this:
select {[Measures].members} ON COLUMNS
from [mycubename]
But I don't know how to populate the second column... Any Ideas?
Something like
select {[Measures].members} ON COLUMNS,
{[Dimensions].[first].members} ON ROWS
from [mycubename]
which would work against any cube if the cube name is given in the from clause.
This works in Microsoft SSAS, so you may need to tweak the syntax for Mondrian:
SELECT Measures.DefaultMember ON COLUMNS,
Dimensions(1).Members ON ROWS
FROM [Cube]