Do you have any clues why excel is presenting more dimention members when i add measures to grid?
When there is no measure selected then there is for example 3 members visible, when I add some measure then there is 5 and with next measure there is 6 dimention members visible. All measures are non empty - there are some values. Can it be some excel setting or dimention?
I have not yet checked the mdx query from excel to the cube.
I've found that there is default member when no measure is selected so setting it will give answer for first case. In production env there is plenty of measures and without explicit setting, default is first measure from first group so it can have different nonempty set than other measure when sliced by given dimention.
But I cant figure out why adding second measure to grid also generates larger dimension member list - measures have values on every row.
I've found there can be cache problem in such case.
Excel is not key I think, in SSMS you can reproduce too.
First case - no measure -> one measure.
When no measure is selected there is deafault used by SSAS.
Deafault cube measure can be checked by:
SELECT NON EMPTY { [Measures].DefaultMember } ON COLUMNS
Changing default as null = no members in rows:
CREATE MEMBER CURRENTCUBE.MEASURES.UseAsDefaultMeasure AS NULL, VISIBLE = 1;
ALTER CUBE CURRENTCUBE UPDATE DIMENSION Measures, DEFAULT_MEMBER = [Measures].UseAsDefaultMeasure;
Changing as 0= all members in rows:
CREATE MEMBER CURRENTCUBE.MEASURES.UseAsDefaultMeasure AS 0, VISIBLE = 1;
ALTER CUBE CURRENTCUBE UPDATE DIMENSION Measures, DEFAULT_MEMBER = [Measures].UseAsDefaultMeasure;
Or you can set any other measure.
Second case - one measure -> two measures.
NON EMPTY is default excel setting in MDX queries so in my case there was overlooked 2 rows without first measure value, so empty members were eliminated. All values are set for second measure so new rows appeared.
So everything works as designed.
Related
Usually I display a value for dimensions by using the CurrentMember.Value/caption as as an alias.
For the following query this breaks with an error along the lines of
'The hierarchy [Measures] appears in more than one axis or in an axis/axes and a slicer too'.
Which I understand.
So how do I edit/expand the query such that I see the book values on rows (normally achieved with
'WITH Member [Measures].[Book_Label] AS [Book].[Book].CURRENTMEMBER.MEMBER_CAPTION'
and the column dimension values along the top?
(Excel image below, values white color'd out as on client site.)
SELECT
NON EMPTY ([Ccy].[Ccy].[Ccy])
ON COLUMNS ,
NON EMPTY
([Book].[Book].[Book])
ON ROWS
FROM [TraderCube]
WHERE
([Date].[Date].[ALL].[AllMember].[2019-12-12],[Measures].[JTD.SUM])
I have made more progress however this comes out staggered duplicating the row / book label at each repeated currency.
Does anyone know how I would:
1) Get the currencies along the top?
2) Have one row / book label per row?
WITH
Member [Measures].[Book_Label] AS [Book].[Book].CURRENTMEMBER.MEMBER_CAPTION
SELECT
NON EMPTY (HIERARCHIZE(([Ccy].[Ccy].Members, {[Measures].[Book_Label],[Measures].[JTD.SUM]}), POST))
ON COLUMNS,
NON EMPTY (HIERARCHIZE([Book].[Book].Members, POST))
ON ROWS
FROM[TraderCube] WHERE ([Date].[Date].[2019-12-13])"
As an update for anyone who comes across this thread/question, for me I am writing a C# layer that translates simple user words and constructs MDX. I query the remote cube and then I return a 2D array. Up until now I constructed the headerRow etc myself and I returned the row dimension labels using the MDX itself.
I have now discovered that metadata is available on the AdomoClient libraries I am using.
This tutorial has inspired me:
https://www.codeproject.com/Articles/28290/Microsoft-Analysis-Services-2005-Displaying-a-grid
It's not a direct answer to my query of getting all of the labels in MDX but it will mean I can construct my headerRow (may be more than one row as seen in Excel pivots) and populate my row labels differently using the positions property of each Axes on the set (Axes[0] is columns, Axes[1] is rows) and the Positions property has a member property too.
I am new to SSAS. Have added a new dimension to cube and when i see under members it shows the value of that columns but under browser section when i drag and drop the dimension it does not display anything
We need more information on what steps you took to get where you're at.
Do you have a relationship between the dimension and measure group?
Did you process the dimension, the cube?
I believe what is happening is that you haven't included a measure in the cube browser so it returned only the report dates which have a value for the "default measure". If you go to the first tab of the cube designer and right click on the cube node above the measure groups list on the left and choose Properties you will see a DefaultMeasure property. You can set that property to choose the measure which is the "default measure" when a user doesn't specify a measure in their report.
However I would recommend just dragging a measure into the cube browser to explicitly tell it to show report dates that have a value in that measure.
I also prefer not setting the DefaultMeasure property and adding the following to the MDX script so that the default measure is always null. That forces users to explicitly add a measure to their pivot so it is clear what they want.
CREATE MEMBER CURRENTCUBE.[Measures].[NullCalc] as NULL
,VISIBLE=0;
ALTER CUBE CURRENTCUBE UPDATE DIMENSION Measures, DEFAULT_MEMBER=[Measures].[NullCalc];
I am trying to produce an Excel PivotTable which displays and compares Sales Rep revenue figures based on values specified by the user, for example, the InvoiceYear.
This data is coming from an SSAS cube and I have connected to it using PowerPivot. I have columns from the cube in the data model and I am attempting to edit the MDX code in the Table Properties window to create some new columns.
This works so far, but the InvoiceYear value is hardcoded to '2010' at the moment. I need a way for this code to accept a value entered into a cell by the user in the excel worksheet itself.
I am just a beginner at this, so I am not aware if this is even possible.
If this approach is NOT possible, I really need to find another way to do it. Come at it from the other side and refresh the column whenever the cell changes via a macro or vba? Some other solution?
Here is what I have in the Edit Table Properties window. This works correctly, but I can't have the Year value hardcoded like that or users will not be able to specify a custom Year value, obviously. I have tried everything I can think of to reference a cell in a Sheet, but the column usually just appears empty with no errors.
WITH MEMBER RentalSales AS
CASE when [SalesRep_Dim].[InvoiceYear].currentmember.membervalue = '2010' then [Measures].[LineAmountMST] else 0 end
SELECT NON EMPTY { Measures.RentalSales, [Measures].[LineAmountMST] } ON COLUMNS,
NON EMPTY { ([SalesRep_Dim].[InvoiceMonth].[InvoiceMonth].ALLMEMBERS * [SalesRep_Dim].[InvoiceYear].[InvoiceYear].ALLMEMBERS * [SalesRep_Dim].[SaleRep].[SaleRep].ALLMEMBERS * [SalesRep_Dim].[ItemGroup].[ItemGroup].ALLMEMBERS * [SalesRep_Dim].[Site].[Site].ALLMEMBERS * [SalesRep_Dim].[Source].[Source].ALLMEMBERS * [SalesRep_Dim].[Type].[Type].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM ( SELECT ( -{ [SalesRep_Dim].[InvoiceMonth].&[]&[0], [SalesRep_Dim].[InvoiceMonth].[All].UNKNOWNMEMBER } ) ON COLUMNS FROM [GMFSalesTransRepRevenue]) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
I don't believe it is possible with your current approach. However if you switch to using Power Query to get data from SSAS and load to Power Pivot it should be possible.
Power Query can query SSAS as described here. The you read a cell in the Excel workbook that the user has entered and filter the data coming from SSAS in the Power Query.
You should look into slicers, they are more appealing visually and you can use them to filter multiple pivot table with one selection.
Setup a report filter and setup your slicer to the same attribute, you can use the Cell for your formula references and use the slicer for user input.
This should be as easy as selecting your pivot table, going to the Insert excel Tab, under Filter there show be the "Slicer".
Select the attribute you are trying to filter by, and your slicer is done.
There is an option to create a write-back measure. You may convert its value to calculated member which takes place in your pivot table. However it's not a best practise. I'd recommend to avoid this method.
Steps:
Create a view (one column int, for example).
Crate a measure group from this view.
Add a partition with writeback settings, see: http://bidn.com/blogs/DevinKnight/ssis/1768/ssas-creating-and-using-a-writeback-measure-group
Create a calculated measure, for example:
(StrToMember('[SalesRep_Dim].[InvoiceYear].&[' + Cstr([Measures].[WriteBackMeasure]) + ']'), [Measures].[LineAmountMST])
where [Measures].[WriteBackMeasure] is your writeback measure and if [Measures].[WriteBackMeasure] = 2010 then you'll get the following:
([SalesRep_Dim].[InvoiceYear].&[2010], [Measures].[LineAmountMST])
Open two pivot tables: one with [Measures].[WriteBackMeasure] only, another is your report with the calculated member.
I'm creating a member in an mdx query containing my slicer information and the last one is my measure. When I add a set to my tuple (for having multiple slicers on one dimension), i get this error.
This function expects a string or numeric expression for the argument.
A tuple set expression was used.
When I add one of the 2 members of my set to my tuple, I don't get this error.
what does this mean, I don't really know what to make of this, fundamentally there isn't a difference between adding a slicer or
A tuple is a cell. A set contains cells. A set cannot be one of the coordinates of a tuple, as the end result is not a cell (a cell is given by 1 and ONLY one member in each dimension, where unspecified members will be taken to be either the All member or the Default member.
The way around it is by creating calculated members:
With Member [Time].[Current Period] as { [Time].[2013], [Time].[2014] }
Select (... your query here ...)
Where ( [Products].[My product], [Time].[Current Period], ... )
In the slicer you in fact have a tuple, as in each dimension a single member is specified. The fact that the member on the Time dimension is not a "pure" member coming from a dimension table column but instead is a calculated member has no influence.
Without your actual code it is difficult to help you.
Anyway, from your question it seems you are confused with sets and tuples (e.g., you cannot add a set to a tuple). I would advise you to check a MDX tutorial explaining these basic concepts: e.g., the icCube gentle MDX introduction should be fine for that.
I have a fairly complex calculated measure that works perfectly for each row of data from a cube. However, I then need a sum of those values line by line. But the behavior of calculated measures seems to be in the subtotal and total lines in Excel, it's performing the calculation again instead of summing the previous rows. Is there a way to have a calculated measure that performs it's calculation on each row, but they does a traditional SUM in the total and subtotals?
Thanks in advance.
A calculated measures does not aggregate; it will be computed each time.
There is a solution, but that is really ugly:
You would have to use something like
SCOPE([dim1].[hier1].[All]);
[Measures].[MyCalculatedMeasure] = Sum([dim1].[hier1].[bottomlevel].Members, [Measures].[MyCalculatedMeasure]);
END SCOPE;
for all hierarchies of all dimensions, be it an attribute or user hierarchy, replacing dim1, hier1, bottomlevel as appropriate.
You need to immitate real measure behavior for calculated member. Make dummy real measure with Null value and then use Scope to define your formula on the granullarity level. For more detailed answer see here: http://blog.crossjoin.co.uk/2013/05/29/aggregating-the-result-of-an-mdx-calculation-using-scoped-assignments/
I found the easiest way to do this:
Create a new named calculation in the appropriate measure table in your DSV. (Right click, add new named calculation and set its expression to be CAST(NULL as [insert appropriate data type]).
Add the new named calculation as a measure in your cube.
In the calculations area of your cube switch to script view and add the following:
({[Measures].[The named calculation you created in step 1]},Leaves())=Your complex calculation;
This sets the definition at the leaf level and all the aggregations work perfectly.
Ref: http://sqlblog.com/blogs/mosha/archive/2005/02/13/performance-of-aggregating-data-from-lower-levels-in-mdx.aspx