SSAS Two Data Sources in one Cube - ssas

I have 2 data source which is Hospital A and Hospital B that have same structure.
On Data Source View , I add same table for Hospital A and Hospital B like this ->
enter image description here
then I add hospital_key attribute in the fact table which are table ADMISSIONS to uniquely categorized by hospital.
then I set ADMISSIONS table as fact for each of the hospital. Then the cube would be like this enter image description here
My problem is
I able to visualize just one hospital only like this-> enter image description here
How can I visualize for the both Hospitals? Please Help!
or Did I do wrong?

I think you are asking is how to rationalise your source objects in the Data Source View?
If so, the tables have the same structure for both Hospitals so you could UNION them together in a named query e.g.
SELECT MyColumns, 1 AS hospital_key FROM AdmissionsTable1
UNION
SELECT MyColumns, 2 AS hospital_key FROM AdmissionsTable2
If needed, repeat for patients data. I am assuming that you only need 1 Sexes table likewise.

Related

Combine data of two columns in power bi and combine set for new table

I have two tables:
Table #1 - recipe:
Table #2 - cakes:
What I want in PowerBI is:
select material (done)
show table with all the recipes versions
show another table with all the cakes baked based on recipe (and previous versions)
So far so good, I've create a custom table with material, cakematerial and recipematerial.
Now I also would like to have another report/table showing orders with the same lot and order-prefix.
For example: Ordernr 2000-010 and ordernr 2000-020 have the same LOT (lt011c). I want these to be shown in one table and then another table with the recipes (and history) belonging to both orders.
So in this case: Recipenr L10-BACK01 and L11-BACK01 with complete version history.
Is that possible?
Datamodel in Power BI:
The answer was to change the relationships to both directions between the 3 tables. This would allow you to filter from any table related to Material

Table structure for reporting SQL Performance

I am not sure if this is the best structure for what I am trying to do.
I have 2 tables.
First table called Team which contains 3 columns, Team ID, Team Name and Kit Colour. This table contains data about the team only.
Second table called player name contains 3 columns, Player ID, Player name and Team ID. More columns will be added soon. Player table is about the player only. Team ID is the foreign key which links both tables together. A team can only have 15 players max so there can be 15 player entries for each team.
There can be thousands of teams with a maximum of 15 players each.
I have a horizontal Report that I need to fill that looks like this:
Team Name | Player 1 Name | Player 2 Name | Player 3 Name....| Player Name 15
My question is, I this best table structure set up for the report? How would I get data of a certain team with performance in mind? For example I want information for Team A, and all its players. There can be 15 players. If I can display the information in one select statement from left to right, I can easily fill in the report but this can t be done without using multiple selects which can be negative towards performance.
The other table structure that was suggested was having join both tables together instead of 2 table. A column for each player and their properties would have a column as well but this does not look correct as table would be massive and more player properties can be added.
I am using SQL 2008
You need to have two separate tables one for team and one for players, since team attributes can be common for multiple players it's better to have them separated rather having all together and duplicating, in your case TeamID serves as the link between both team and player table. so two table with a one to many relation ship is your ideal choice in my opinion.
To retrieve the information of a specific team you can use a simple join and a select statement
SELECT *
FROM TEAM T
INNER JOIN Player P
on T.TeamID=P.TeamID
WHERE T.TeamID=''

hierarchy relationship power pivot

I m trying to show a table where sales are broken down by each sales person with their respective target
I would like to do it in the most efficient way as possible which I think mean fewer table as possible,
District are unique in Geographic split table,
I would like to show for each sales person their sales and target as in results table ..I think I ll have to go through hierarchy but I m not sure how to go about it
I have tried create a table for district and table for sales force with unique columns...but I can get them to show in one table without creating table for each type of sales force.
Thanks for any advice

SSAS - Is there a way to have a dimension relate to a fact table based on two columns in the fact table?

In SSAS is there a way to have a dimension relate to a fact table based on two columns in the fact table?
We have two tables: Location (Dimension) and Sales (Fact). The Location dimension has one column: "state". The Sales table has three columns: "saleAmount", "customerState" and "billingState" (because our customer can be in California but wants us to bill a company or branch in New York).
In SQL, if we want to see all the sales in California, we write our SQL query as:
select sum(saleAmount) from Sales where customerState = 'California' or billingState = 'California'
Is there a way to accomplish this in SSDT when building my cube so that when I'm using Excel as an end user tool and I select the state attribute from the Location dimension and the saleAmount measure, the saleAmount will be based on customerState or billingState? (I do not want to have role playing dimensions here - where one Location dimension is based on customerState and another Location dimension is based on billingState. I want one dimension matching up with both columns at once.)
Not the way you're thinking, but you can achieve what you want by doing this:
Create a view on your fact table, that is a UNION of facts related to customerState and facts related to billingState. This means the view will only have 1 State column, and if a fact has different values for customerState and billingState, then it will have two rows in the view.
Use the view instead of your table to populate your measure group in the cube.
Link the measure group to the Location dimension on the single State column in the Fact view.
Builder beware, this results in duplicate counting of facts when rolling up states where a single fact is in two different states.

Retrieve data from two different table in a single report

I have two table Employee and Salary table, salary consists Salary of employee in a field named Salary_employee.
Second one is Extra Expense, Extra expense consists records related to extra expenses of a company like electricity bills,office maintenance in a field named extra_expense.
(Their is no relationship between these two table).
Finally, I just wanted to show all the expenses of company in a report, for this i need to group both the table. what to use here join or union ??.
If there is no relationship between the two tables, then this really cannot work since you dont know where the expense is supposed to tie into. You should redesign the database if possible as this sounds impossible based on your description.
UPDATE
OK, by the look of your screenshots, I am guessing that this database only stores one companies info? And not multiple?
IF that is correct, AND if all you want to do is squish the data together into one flowing report of expenses, then I would indeed suggest a UNION. A JOIN would not give you the flow you are looking for. A UNION will just smash the two outputs together into one...which I think is what you are asking for?
SELECT ext_amount AS amount, ext_date AS date_of_trans
FROM extra_expenses
UNION
SELECT sal_cash AS amount, sal_dateof_payment AS date_of_trans
FROM employee_salary
It sounds like you don't need to use group or join. Simply query both tables separately within a script and handle them both accordingly to their structure to produce a report.
Join and union are functions which you can use to extract different information on a common thing from separate tables. E.g. if you have a user whose private details are stored in one table, but their profile information is in another table. If you want to display both private details as well as profile info, you can join the two tables by the common user name in order to combine and gather all info on the user in one query.