MDX - Counting attributes where no relation exists - mdx

I have a Dimension (Account) with two attributes - Group and Account. The cube is a pre-built one and has no hierarchy defined on these attributes.
I need to write an MDX query that could provide me with number of accounts against each group.
Changing the cube is not an option so I am looking for a purely programmatic solution.
This could be fairly simple in T-SQL but doesn't seem so straightforward with MDX.

Related

relationship between 2 fact tables in dimension usage - SSAS

I have 2 fact tables. One is being used as a dimension - Bridge table for multi valued Dimensions. The other is FactSales. What I am trying to achieve is to get a count of customers from sales table where they have a specific member property (comes from the other Fact Table). I thought making the relationship between the two is the way ahead.
I tried using the PersonID as the join in Dimension Usage tab, trying both regular and References (using DimPerson) but it didn't work. Does anyone know why this might be? Or what is the way around this?

How to manage attribute permissions on SSAS Tabular model

We have a Tabular model with several Fact tables and several Dim tables.
We would like to manages roles so that specific roles will not be able to see members of a certain attribute within a dimension.
So in an HR cube with a "Work Hour" measure - i would like to block a specific role from seeing the "Employee Name" attribute but still show the sum of "Work Hours" to the total employee.
While using multidimensional, i simply used an MDX expression which filters on the "All" member of the dimension thus showing the total but not the members of an attribute.
Don't know how to do so in Tabular Model.
Did someone encounter a similar request?
Thank you!
Yes, Tabular models don't give you the option of disabling "visual totals". So this isn't easy to do. However if you get creative you can do it. If you remember that calculated columns are calculated at processing time without security then you can store the rollups you need ahead of time. Store those rollups somewhere users can read them from even with security in effect. In this case you may need to put the rollups in a separate table, separate from the employees since all rows in that table will be hidden. Here is a full write up:
http://cathydumas.com/2012/05/19/row-security-and-hierarchiespart-1/
However in your case since you want to hide all Employee table rows that will cause all related fact table rows to disappear due to security. So here is what I would suggest. First, disable the relationship to the Employee table. Second, pattern your measures after this pattern:
Work Hours := IF(
COUNTROWS(Employee)>0,
CALCULATE(
SUM(FactHours[Work Hours]),
USERELATIONSHIP(FactHours[EmployeeKey], Employee[EmployeeKey])
),
SUM(FactHours[Work Hours])
)
The logic here is that if your user can't see any employees then don't enable that relationship. If your user can see employees, then enable the relationship.

how to apply a filter (based on unrelated dimension )on a measure

I have a problem in my SSAS cube:
There are two fact tables: OrderFact and PaymentFact, when I filter a date, I want to see payments related to filtered date orders. I designed a cube as follows, but I don’t get the desired result, can anyone help me out of this:
You will need to setup a many-to-many Date dimension. Basically you will have two measure groups in the cube. Then on the PaymentFact measure group you will go to the Dimension Usage tab of the cube designer and setup DateDim as a many-to-many relationship type using OrderFact as the intermediate measure group.
For more background about many-to-many dimensions in SSAS, I would highly recommend this whitepaper:
http://www.sqlbi.com/articles/many2many/
The other option is to copy DateKey to PaymentFact in your ETL then make it a regular relationship. If a Payment only relates to one order, then that's feasible. If a payment relates to multiple orders, then use the many-to-many relationship.

Why are there no hierarchies based on time?

Why is it not necessary to define a hierarchy using the Date attribute from a date/time table?
The Analysis Service project seems to want me to create a hierarchy within my Dimension -- the tooltip says "Create hierarchies in non-parent child dimensions". I really had none that came to mind, so I tried adding a the PK Date attribute from my Time table, and creating a hierarchy with that.
When I do this, I get the error "Errors in the high-level relational engine. The 'dbo_Orders' table that is required for a join cannot be reached based on the relationships in the data source view."
I noticed in the AdventureWorks sample never uses Date in a hierarchy. Why is this?

Joining fact tables in an MDX query

I am building and Anaysis Services project using VS 2005. The goal is to analyse advertising campaigns.
I have a single cube with 2 fact tables
factCampaign: which contains details of what people interviewed thought of an advertising campaign
factDemographics: which contains demographic information of the people interviewed
These fact tables have a common dimension dimRespodent which refers to the actual person interviewed
I have 2 other dimensions (I’ve left non relevant dimensions)
dimQuestion: which contains the list of questions asked
dimAnswer: which contains the list of possible answers to each question
dimQuestion and dimAnswer are linked to factDemogrpahics but not factCampaign
I want to be able to run queries to return results of what people thought about campaign (from factCampaign) but using demographic criteria (using dimQuestion and dimAnswer)
For example the how many Males, aged 18-25 recalled a particular campaign
I am new to OLAP and Analysis Services (2005) so please excuse me if what I am asking is too basic.
I have tried the following options
Linking the to factTables in the datasource view using the common RespondentKey. Queries run and return results but the same result is returned regardless of the demographic criteria chosen, i.e. it is being ignored.
Creating a dimension from factDemographics. I have tried to connect dimAnswer to factCampaign in Dimension Usage tabe of the Cube Structure but with out success. Either the project just stalls when I try to deploy it or I get the following error (note the attribute hierarchy enabled is set to true)
Errors in the metadata manager. The 'Answer Key' intermediate granularity attribute of the 'Fact Demographics' measure group dimension does not have an attribute hierarchy enabled.
I would appreciate any help that anyone can offer. Let me know if you require more info and again apologies if this is a basic question
What you probably need is a many-to-many relationship. There is a whitepaper here which goes through a number of scenarios for m2m relationships including one specifically around surveys and questionaires.
For anyone who is interested the solution was to alter the dimRespondent to include the questions and answers. And in the Dimension Usage tab of the Cube design to set dimRespondent to have a Regular relationship to both fact tables.