combining multiple SSAS queries as one dataset - ssas

I have a fact-table with one date dimension linked three times to attributes for Ordered, Prepared and Shipped dates. So, I am able to get counts on ordering, manufacturing and dispatch and currently I am running these as three separate excel pivot table requests and combining them into one graphs giving three bars per month. I am wondering if there is a more sleek way I should be doing this by which I write a query which returns the three separate counts as individual measures rather than running the query three times doing it once against each dimension.
Currently, the fact table looks something like this: -
DEPID, PRODCODE, ORDERDATE, PROCESSDATE,SHIPDATE
001,001,20120101,20120102,20120104
002,001,20120103,20120105,20120106
003,002,20120104,20120106,20120107
004,002,20120105,20120107,20120108

You could create 3 calculated measures in the cube (Ordering Count, Manufacturing Count, Dispatch Count)...then just drag them into your pivot table in the values section and use a date dimension in the rows group.

Related

Group by in Orange, Data mining

I have a dataset for a supermarket, each transaction containing an item is represented in a row. So, if transaction 1 contained milk, bread and coffee, the items are on a separate row and the attribute transaction occurs three times. What I want to do is to group transactions by item so that all the items are concatenated in one column. Then lastly apply association rules and separate each item in a column as an itemset. Is this even possible in Orange?
Worth mentioning, I managed to do this in RapidMiner easily with the same dataset. I used the Aggregate operator, concatenated the item attributes and then grouped by transactions.
If I understand this correctly, you wish to aggregate columns, not rows. If so, there's Aggregate Columns widget available for that. To perform Group by on rows, there's currently Pivot, which has a Group by output. We are working on a separate Group by widget, which should be available in the next release.

Remove duplicates from fact table to calculate measure correctly

I'm very new to data warehousing and dimensional modelling. For a uni project I started out with a database that I need to turn into a data warehouse for analyses. To end up with a clean star schema, I had to denormalize a few tables into 1 fact table. The downside to this is the amount of redundancy.
Below is a part of the data from the fact table:
A voyage consists of multiple shipments, and a shipment can consist of multiple different items. In this example, containers 1-2000 of shipment 1 contain item 3, and containers 2001-5000 contain item 1. The total amount of containers for this shipment is 5000, obviously. However, for data analysis purposes, I need to calculate a measure for the total amount of containers per voyage. This presents a problem with the current fact table, because I have a record for each different item. So for voyage 1, the actual total amount should be 9200, but because of the duplication I'll end up with 19400, leading to an incorrect measure.
I need to find a way to get rid of the duplicates in my calculation, but I can't find a way to do so. Any help would be much appreciated.
What you'll need to do is group by your shipments (CTE, inner query, temp table, etc) to get the number of containers per shipment, then group by your voyages to get the number of containers per voyage.
Here's an example with an inner query:
SELECT voyage_id, SUM(num_ship_containers) AS num_voyage_containers
FROM (
SELECT voyage_id, shipment_id, MAX(container_end) AS num_ship_containers
FROM ShippingWarehouse
GROUP BY voyage_id, shipment_id
) AS ship_data
GROUP BY voyage_id;
voyage_id
num_voyage_containers
1
9200
Try it out!

Multi-dimensional to Tabular mapping one column to several

I have the following mapping within an old multi-dimensional cube:
Each one of these 3 INVOICE_FACT columns maps to the same sman_key column within the salesman table. I know within tabular that only one column is permitted to be mapped to another column.
How can I replicate this relationship within tabular?
The two standard approaches to this issue are to either create multiple relationships between the two tables (only one relationship can be active at a time) or to import the salesman table multiple times with different names (e.g. salesman, supervisor, driver).
Without knowing more about the way that your data model is being used, it is hard to recommend the approach to use, but I tend to favour importing the salesman table multiple times.
If you use inactive relationships, a key function to know is the USERELATIONSHIP() function which specifies that a particular calculation is to occur using an inactive relationship.
https://www.sqlbi.com/articles/userelationship-in-calculated-columns/ provides some example of this technique where the relationships are to a date dimension, and you want to have measures which accumulate sales amounts according to Order Date, Due Date, or Ship Date (as per AdventureWorks) e.g.
SalesByDueDate :=
CALCULATE (
SUM ( FactInternetSales[SalesAmount] ),
USERELATIONSHIP (
FactInternetSales[DueDateKey],
DimDate[DateKey]
)
)

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.

Multiple Joins from one Dimension Table to single Fact table

I have a fact table that has 4 date columns CreatedDate, LoginDate, ActiveDate and EngagedDate. I have a dimension table called DimDate whose primary key can be used as foreign key for all the 4 date columns in fact table. So the model looks like this.
But the problem is, when I want to do sub-filtering for the measures based on the date column. For ex: Count all users who were created in the last month and are engaged in this month. This is not possible to do with this design, coz when I filter the measure with create date , I can’t further filter for a different time window for engaged date. Since all the connected to same dimension, they are not working independently.
However, If I create a separate date dimension table for each of the columns, and join them like this then it works.
But this looks very cumbersome when I have 20 different date columns in fact table in real world scenario, where I have to create 20 different dimensions and connect them one by one. Is there any other way I can achieve my scenario w/o creating multiple duplicated date dimensions?
This concept is called a role-playing dimension. You don't have to add the table to the DSV or the actual dimensions one time for each date. Instead add the date once, then go to the dimension usage tab. Click Add Cube Dimension, and then choose the date dim. Right-click and rename it. Then update the relationship to use the correct fields.
There's a good article on MSSQLTips.com that covers this topic.