Is it possible to use an external field in the calculation for a pivot table column? - mdx

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/

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 Rank with respect to multiple measure and dimension

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.

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]

Grouping Pivot Table Values/Metrics/Calculated Fields into one Field to put in report filter

Say I wanted to group all my metrics that I have in my values in my pivot table(including all added calculated fields) into one field to be able to use in the Report Filter.
So I want all those values in a drop down to be able to select a metric and it populates my pivot table below.
Is that possible with VBA Code? Am I explaining clearly?

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]