I am trying to determine the best way to model the scenario of employee turnover for a Dimensional Model. I am not sure if its best to include the Termination_Count and Headcount in the same measure.
I currently have a headcount measure with both termed and headcount:
**Headcount Measure:**
Employee_id
Department
Employee_count
Termed_count
Month
So each individual employee will have a row created for them if they are active during the month or if they are terminated during the month.
How have other people worked with employee turnover issue.
Don't track Headcount and Turnover in the same table, they have different grains.
Headcount: being a semi-aditive measure you need a snapshot fact table counting employees per department, salary level, bureau and whatever other dimensions you need. It should store these values once per day;
Turnover: have a Hire/Fire transaction table with three measures: employees_hired (0/1), employees_fired (0.1) and net_employee_variation (=1/0/+1). On the employee dimension you can have a "date_hired" and "date_left_ as attributes to allow, for example, counting time between the two events.
But you shouldn't mix what is a transaction fact table with a snapshot fact table.
Related
I would like to SUM the price of these Order Items together for each Order for a Contract.
I want to reduce my granularity from hourly to daily and so reduce the row count that we pass to the fact table and then the SSAS cube.
i.e. Contract A which can have many Orderlines, consider Orderline 1 which can have many Order Items.
I have had to screen the Order Items, but they are just sequential id numbers.
The problem is that I have to roll this up to a daily granularity from hourly, but still be able to give users on the cube access to the Order Item level
you can use SUM as a window function. this will effectively write the same sum to multiple rows for each order-item; just like the price.
for example
SELECT ......
, SUM(price) OVER (PARTITION BY order_item)
....
FROM ....
GROUP BY ....
I have an ERD.
The Stationlog table logs which employee worked at the station and at what time the employee logged in and out. The station produces orders.
As of now there can only be 1 employee logged in at a station but I am trying to figure out how I can have multiple employees in a stationlog. I want one Employee to be the manager within that Stationlog and give him the ability to add an infinite amount of employees to that stationlog.
I have tried adding fields such as employee1, employee2, employee3 in the Stationlog (not shown in this ERD) but that means I cannot add an infinite amount of employees to each stationlog.
How would I be able for one manager (who is an employee) to be able to add x amount of employees to 1 Stationlog?
Your current design is that one specific Stationlog row refers to exactly one Station and one Employee. Another Employee for the same Station would imply that there's a different Stationlog row for that other employee. (hopefully not overlapping with the first). Nothing prevents 10 employees working at the same time on the same station, each with a different log entry.
If this is not sufficient, and you want one employee define the "session" with login and logout time but allow several employees on that log, you'd need to make the relation Stationlog >o----|< Employee many-to-many.
Of couse many-to-many is easily drawn on the diagram, but would require an association table for its implementation to hold the valid pairs.
Stationlog >o------ Logteam ----|< Employee
------------
StationlogID
Employee
(OrderOfArrival etc...)
In Logteam you'd put everything which is specific go a given session and a given employee, such as arrival/departure, if this could be different from login/logout. If managers are predefined, you'd put a IsManager flag in Employee table. But if it's dynamic, e.g. the first who come (or has the key for the station), then you'd put this flag in this association table as well
with regard to the following question and the given response I have the following question:
I am facing the same issue, but creating a bridge table like mentioned above is no option in my case as I still need the separate dimensions for other operations and different analysis.
For budgeting reasons I have to show all customers even if they have no match with the fact table. Enabling the corresponding option in EXCEL obiously leads to a cross join of the selected dimensions resulting in a complete list of all customers in all countries, although not each customer exists in all countries.
Is there another altrnative to force SSAS respecting relationships defined?
Many thanks in advance for assistance.
Let’s say you have FactSales with CustomerKey, CountryKey, DateKey and SalesAmount. When you build a PivotTable in Excel with Customer and Country on rows and SalesAmount on columns it only shows customers with sales. If you set Excel to show rows with no data it shows all customers in all countries.
Try building a new FactCustomerCountry table with CustomerKey and CountryKey only. Create a measure Customer Country Count.
Then create a new calculated measure:
CREATE MEMBER CURRENTCUBE.[Measures].[Sales Amount with Zeros]
AS
IIF(
IsEmpty([Measures].[Customer Country Count]),
Null,
CoalesceEmpty([Measures].[SalesAmount], 0)
);
Use that measure in your PivotTable instead of SalesAmount. Do not show rows with no data. The measure should return meaningful Customer-Country combinations and should return all customers.
Hi you can solve your issue in MDX. Take a look at the query below, its an example on Adventureworks. This will fetch all the products that were sold and the quaters that they were sold in.Now some products were never sold, I still want to see those product.
select [Measures].[Internet Sales Amount] on columns,
--non empty
{filter(([Product].[Subcategory].[Subcategory],[Date].[Calendar Quarter of Year].[Calendar Quarter of Year]),[Measures].[Internet Sales Amount]>0),
filter(([Product].[Subcategory].[Subcategory],[Date].[Calendar Quarter of Year].defaultmember),[Measures].[Internet Sales Amount]=null)
}
on rows
from
[Adventure Works]
I don't know how to perform the the following case.
I have the sales info in a table:
Number of Bill (key),
Internal number (key),
Client,
Date (month-year),
Product group,
Product,
Quantities,
Total,
Sales man.
I need to joint this sales tables with the annual forecast sales table that is the next one:
Date (key),
Group product(key),
Sales man (key),
Total.
In each tables the combination of the key is the primary key. I need to add in the sales tables the forecast. For this I need to add the sales of the forecast in the real sale only on the first match of date, group product and sales man, so the total of forecast sales don't get bigger than it is (a sales man can sell the same group product, to the same client, in the same day on multiple times).
.. only on the first match of date, group product and sales man ..
You can use window functions for this, consider using ROW_NUMBER() OVER(PARTITION BY ... ORDER BY ... ). First match has row number of 1.
More information and examples (sales!) can be found from MSDN.
I am confused where should I start to design a star schema.
for example
I have tables in database as follows:
Branch(branchNo, bStreetAddress, bCity)
LoanManager(empNo, empName, phone, branchNo)
Customer(custNo, custName, profession, streetAddress, city, state)
Account(accNo, accType, balance, accDate, custNo)
LoanContract(contractNo, loanType, amount, loanDate, empNo, custNo)
I want to design a data-warehouse to analysis the loads
such as :
The total amount of loans in 2008.
For the type of loans with more than 10 loan contracts, the type of loan and the number of contracts
when creating a star schema, what where should I start?
For what I understanding, all the star schemas must have a center, and the center fact table, contains "Measures" and "Relations to other fact tables".
So, is it that, when designing the star schema, we always start from the center,
confirm what are the measure first? and then choose proper relation to another fact table?
But I still have another question, what should we choose to be Measures?
When choosing measures, what question should I ask myself?
The design of a star schema is always driven by the client's business needs. What are the questions asked? How fine-grained should the answers be?
In you example, interesting questions might be "Number of Contracts by Branch or LoanManager" or "Managed sum of Loans by Branch or LoanManager". In this case, Branch and LoanManager would become your dimensions while Count(LoanContract) and Sum(LoanContract.amount) would be your measures. A common additional dimension is time, usually week or quarter.
The schema for answering those questions could look like this:
DimBranch ( branchNo )
DimLoanManager ( empNo )
DimQuarter ( year, qNo ) -- qNo in (1,2,3,4)
DimWeek ( year, weekNo ) -- weekNo in (0..53), depending on business rules
Measures ( branchNo, empNo, year, qNo, weekNo, numContracts, sumLoans )
For the business questions you already posed in your question, the dimensions and measures would be such:
dimension: year, measure: Sum(LoanContract.amount)
dimension: loanType, measure: Count(LoanContract)
Putting those two into the same star schema doesn't make much sense, since they neither share dimensions or measures.