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]
Related
I am trying to extract the following columns from a sql table called Vouchers:
Date,
VoucherID,
ValueIssued,
ValueRedeemed,
Valueexpired
That bit is straight forwards and returns the below data:
However I would like to show them
by day,
by voucherID
and then sum up the values for each individual voucherID to produce a view similar to the below:
Can anyone point me in the correct direction in regards to what sql code will do this?
I am using SSMS 2014
It's pretty straight forward
SELECT PosDate, VoucherId, SUM(ValueIssued), SUM(ValueRedeemed)
FROM Vouchers
GROUP BY PosDate, VoucherId
Note that column DateExpired isn't correct in this context. It should be either grouped by or removed entirely (as I did)
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.
Let us say we have a pivot table, that lists different departments of a school district. (each department being a unique row).
The number of hours of work put in by each department is the 2nd column of the pivot table.
I want to create a 3rd column that lists "dollar amount" spent by each department.
The issue being 'hourly rate' is not part of the cube that is used to generate the pivot table.. The excel spreadsheet has a manually written table that has 2 columns, (Dept, hourly rate).
I am wondering if it is possible to use the external table column 'hourly rate' using my olap mdx calculation?
I think you're asking if you can add some sort of Lookup functionality inside a custom measure to find values that are in the spreadsheet but not in the cube. I don't believe this is possible.
What is possible is the following.
Create a pivot table looking at your cube - this is mine against the AdvWrks cube:
Now, with the pivot table selected, hit this button:
You can now add a standard vlookup formula and drag down the right hand side:
Notice how the slicer of the pivot table has remained - so all formulas are still linked through to your OLAP cube.
The above is possibly some sort of route you might like to explore as a workaround ....or just add some more information into the cube!!
EDIT
This is not a very elegant solution but it is a way you can add your rate into the pivot:
In here select "MDX Calculated Measures..."
Then for my advWrks prototype I added this mdx:
case
when [Product].[Product Categories].CURRENTMEMBER IS [Product].[Product Categories].[Category].[Accessories] then 0.5
when [Product].[Product Categories].CURRENTMEMBER IS [Product].[Product Categories].[Category].[Bikes] then 2.5
when [Product].[Product Categories].CURRENTMEMBER IS [Product].[Product Categories].[Category].[Clothing] then 5
else 1
end
*[Measures].[Internet Sales Amount]
The above measure is called fooBar and can now be used in the pivot along with any other measure:
If there are 600 categories then my case statement will be pretty ugly - but it seems to be functioning as expected.
the previous answer gives your best options with pivot tables.
XLCubed (full disclosure, who i work for) is an add-in which handles this sort of limitation in olap connected Excel, & your scenario is detailed below. Basically a grid (pivot table equivalent) retrieves the SSAS data, and you can then add a user calculated column containing any standard Excel formula, in your case a vlookup:
http://blog.xlcubed.com/2016/06/calculated-fields-are-not-available-in-an-olap-based-pivot-table/
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]
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