MDX - Dimension on rows and Measure and a Dimension on Columns - mdx

I am now adding to something I am writing and need to offer the user the ability to place dimensions and measures on either the rows or columns.
I am about to test an idea to make the MDX for the example in the picture but realised I should also ask any MDX experts too!
So how would one go about pulling off this sort of layout? I cannot view the MDX generated by this Excel (data redacted due to being on site somewhere, also why I cannot download addins for MDX generator etc)

I actually did manage to get the OLAP extension addin installed.
https://github.com/OlapPivotTableExtensions/OlapPivotTableExtensions/releases/tag/v0.8.4
This will help me add some stuff to my MDX generator and prove invaluable as you can see the MDX Excel generates.
SELECT NON EMPTY Hierarchize(AddCalculatedMembers({DrilldownLevel({[Ccy].[Ccy].[ALL].[AllMember]})})) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON EMPTY Hierarchize(AddCalculatedMembers({DrilldownLevel({[Book].[Book].[ALL].[AllMember]})})) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON ROWS FROM [TraderCube] WHERE ([Date].[Date].[ALL].[AllMember].[2019-12-12],[Measures].[JTD.SUM]) CELL PROPERTIES VALUE

Related

Dynamic measure that responds to dynamic dimension

I'll try to describe this scenario without introducing too much irrelevant info, but keeping it simple.
Using the newish Field Parameter feature in PowerBI, I created a Parameter called _Dimensions and another one called _Measures, selecting common columns in the former and common measures in the latter.
I then build a bar chart with [_Dimension Fields] for X-Axis, [_Measure Fields] for Y-axis, and a single-select slicer for each. Now when user selects a measure and a column, it draws a bar chart of their selected measure, sliced by their selected dimension.
What I'd like to do is actually make this a Pareto chart, which would entail putting in a second measure on Y-axis, but rather than having a pareto counterpart to every possible measure a user may select, I'd like to create a single measure that calculates running percent of total of [selected measure] along [selected dimension].
I was hopeful I could call the [_Dimension Fields] column that PowerBI created with its special properties from DAX, but that doesn't seem to treat them any different than any other column. I also tried NAMEOF, but that just returns a string. I was hoping it would act like INDIRECT does in Excel, treating the string as a reference, but alas.
Does the above problem statement make sense? Can anyone describe an elegant design approach to do this dynamically that does not involve just writing a version of every possible measure a user could select and then use a switch?
imagining the combo chart to look like this (pareto measure in line chart part)
edit: secondary question, but equally important to the end goal of a fully functional dynamic pareto: when user selects measure, I want the selected dimension to always be sorted desc by selected measure. This is how you do a pareto analysis, but PBI does not default to sort descending always, and each time you change the dimension (via slicer click) the chart resets sorting. Any way to ensure that the sort order is fixed correctly?
Calculation groups are the way to go and Tabular Editor is used to create these.
After much exploration, here is my solution. It's not 100% dynamic in that it requires writing custom DAX for each dimension and measure that you need to be available for dynamic use, but gets the job done for the scope of the report in question.
create field parameter from columns that I will want to dynamically use in viz: name it _Dimension
In my example, I will be using two columns from two tables: Carrier[CarrierNumber] and ShipmentLane[LaneCity]
create field parameter from measures that I will want to dynamically use in viz: name it _Measure
in my example, I have two measures I will want to be able to toggle between: Events_Late and Events_Late2. Both exist on OnTimePerformanceDetail table.
create measure to dynamically return value based on the selection of
_Measure in slicer on canvas. This seems like it should not be unnecessary with field parameter feature, but it is necessary for reasons that will be
clear if you try to do this without a custom measure.
create a pareto measure for each of the dimensions that may be
dynamically passed to viz. Each of these dynamically evaluates the base measure, but is specific to a single column for which the measure evaluates over:
create a dynamic pareto measure that chooses the correct pareto calculation based on the selection on _Dimension
create single select Slicers for _Dimension and _Measure
create combo chart, using _Dimension for X-axis, _Measure for Y-axis, and DynamicPareto for line Y-Axis. I have aliased DynamicPareto on the viz to Running% so that it shows nicely and clearly on legend
set the sort order of the chart to be ASC by Dynamic Pareto measure. This ensures that the dimension on X-axis is always sorted correctly
A few notes:
I named the dynamic pareto as "Discrete" because this only works as
designed when doing pareto on a discrete dimension, where the bars
are meant to be sorted desc by [measure]. If you are doing a
Percentile chart, which is basically the same thing, but the
dimension is sorted by dimension value instead of measure value, the
Pareto calculation needs to work slightly differently.
There are lots of Pareto measure patterns out there. I used the one
from this blog, because it's concise and performs well:
https://janizajcbi.com/2018/08/22/pareto-rule-abc-class-in-dax/
it is important that the slicers be set to single select
I discovered there is a Pareto 3rd party viz that is simple and
dynamic, but has very limited formatting features. Fine for quick
analysis, but if you have branding or formatting standards, it may
prove unusable, as in my case
in my production use case, I have a lot more dimensions and a lot
more measures that will be available. Started with just 2+2 to prove
out functionality. Just need to follow same pattern to add more
available dimensions and measures to mix.
my naming convention of * suffix is because this report is built on a
centralized data model. The * makes it easy to find measures that are
local to this report and not a base measure in the model I am
connected to.
the field parameter feature can only be used with a remote model like this if the preview feature of Use Direct Query for AAS and PBI datasets is enabled OR the field parameters are added to the base model. In my case, I'm adding the field parameters to the base model, and all of the measures here are local to the report, connected to remote model.

SSAS Dimension not displaying values in rows in Cube Browser

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];

How to display filtered data rows as a tooltip in Tableau Public?

Noob here, I have a table with different entries (rows) per different (repeating) regions.
I'd like to be able to display the data rows filtered - matching that particular region thanks - so I get those particular fields related to each region as a tooltip on a map. (I know how to build the map)
Thank you
Just dragging the fields you want to Details or Tooltip is not doing the trick?
Putting a measure on a shelf (other than filter shelf) includes that field in the visualization query results -- i.e. applies the chosen aggregation function to yield an aggregate result value for each partition of the data (as specified by the unique combination of dimensions)
Putting a dimension on a shelf (other than the filter shelf) also includes that field in the query results, but since the dimensions define how data rows are partitioned, it can affect the level of detail of the query. You'll notice this often as suddenly getting many more marks in your visualization after you add a dimension to a shelf. If you are familiar with SQL, dimensions define the fields that follow the GROUP BY keyword.
EDIT
Thanks for the addition, #AlexBlakemore. I've never said dragging a dimension would not work, only that it wouldn't work as the OP wanted it to (basically the same as you're saying).
And though everything you said (above) is true, it's particularly not exact when it comes to maps. Yes, dragging a dimension will further partition the data, but it will not create additional marks on a map (unless it has also geographical properties). Rather, the tooltip will get the first occurrence of that dimension, and display data for that only. For instance, if you drag "Product" to details, and the possible values are "Bread", "Coffee" and "Milk", it will probably just show "Product: Bread", and the measures for "Bread" only. So yes, it will partition, but no, it won't create additional marks.
Back to OP problem. What I believe you want is a tool tip with all values of the dimension (in my poor example you'd like to see "Bread, Coffee, Milk"). Tableau does not have functions to aggregate strings yet, so it's hard to do so.
What I would suggest is to create a separate sheet, and just drag the dimensions and measures you want to rows. Then put it side by side with the map on a dashboard, and use the map as a filter. Then, when you click on a country/region/city, you'll see the data of that region on the other chart.
Refer to: http://kb.tableausoftware.com/articles/knowledgebase/creating-filter-actions-dashboards
or https://www.tableausoftware.com/learn/tutorials/on-demand/authoring-interactivity

GROUP BY over data in PowerPivot

In my PowerPivot I have a master data table which comes via an extract from system x. Now I want to be able to "GROUP BY" over a certain column from the same data. What would be the best approach here? There are more than 600.000 lines involved.
I have already tried following DAX query but it won't work:
SUMMARIZE('SAP extract', [cost element], sum('SAP extract'[val]))
Returns:
Query(1,, 47) Function SUMMARIZE expects a column name as argument number 3.
Kris,
I would suggest creating a new measure -- guessing from you question, that would probably be a simple SUM (see documentation here), something like:
=SUM(Sales[Amt])
This should be then automatically added to your currently active powerpivot table.
If you then want to group the data by anything, simply drag the dimension into the rows section and you should be able to see the aggregated sums sliced by the dimension you chose.
Hope this helps.

pivot report excel 2007 on ssas

I am very new to this. I built a pivot report (excel 2007) on ssas. It has data, rows, columns. And columns has hierarchy likes day-month. Now I want to send this report to a customer, so he can view it by himself and expand the hierarchy as he likes. But he can only see the contents as I saved the report. E.g. I saved it as month hierarchy and he can only see the monthly figures and can not expand the hierarchy to day. What should I do? The customer has no access to the ssas data source.
Thanks
N. Z
The pivot report needs some kind of a datasource.
Whether it is the cell values of an excel sheet or the connection to the SSAS Cube, it's fine but in order to do drillthrough actions a datasource is obligatory.
There are various workarounds for this:
Export all the aggregated data that you want your user to view to a new spreadsheet and make a simple pivot table based on that sheet.
Setup a role in SSAS and give your user the specific permissions you want him to have on the data. This requires the knowledge of some MDX but simple stuff is autoconfigured. You can then give your user access to the datasource inside of the excel.
Set up a sharepoint installation which is part of the BI (this is a bit of an overkill) and provide your users with dashboards of reports using PerformancePoint Services.
I really don't think that you can browse the data without data(datasource)!!! I would be glad to be proven wrong.