SSAS - Dimension Browser Shows Different Attributes - sql-server

I have a table in the data source view with UserID (PK), Department, UserName (and other irrelevant attributes).
I create a dimension. I select UserID as PK. I select Department as attribute.
So, now I have a dimension table with attributes: UserID, Department.
I create a hierarchy with Department->UserID.
I go to the browser, click All and then it starts showing me values from another columnn that isn't Department. If I expand further down into the UserID level, it shows me the values from UserName instead of UserID.
What the heck is going on here? It is showing me values from an attribute that I did not even include in my dimension. How is this possible?

Did you check attribute relationship view? However you create the dimension and the hierarchy it can be mixed up in attribute relationships so you will have to set the drill logic manually.

Related

Filtering a result by the content of another table

I'm supposed to do a stakked column chart visualization about the total number of permits granted by authorizing department. So far ok, the problem is my datamodel.
My datamodel consists in 3 main tables:
PDT's(work permits)
Departamentos (SubDepartments)
Referencia(Departments)
I leave here the type of relationship between them:
The 1st table below It's about subdepartments. The primary key is the ID Column which is directly related to Nombre Column because It refers to Departments name. The thing is that Each of departments are inside another bigger than 1st one E.G.: Petronor is the biggest department, thats why It is not inside another one and the column name of DepartamentoPadreId is null in this field, but Economico Financiera, Fiabilidad y Mantenimiento, Ingeniería y Desarrollo, Producción, P&O, SMA and OTROS are inside of PETRONOR and this is how works this table.
The problem is that names are too long to put in my Dashboard so what I did was create a new table relating the names from DepartmentoPadreId to another with the acronyms.
Now I have my last table where I have the work permits of employees. This permits are made by a Department for another. This means that I have several relations with this table by Departamentos Table. One relation is with the Authorizing Department and another with Authorized Department. And here is my problem
What I expect to get is two stakked column charts with different values for each one. One: the Total number of permits by Authorized Department Second: The total number of permits by Authorizing Department.
The problem is I'm getting the name from the Relacion-Direccion Table because is the only table that contains the name I want to appears in my dashboard and I dont know how to filter It by the specific column in PDTs table I want.

MS Access: Auto-populate form fields based on multiple tables

I have the following 3 tables:
Retailers - ID, Name
Registration - ID, Status (YES/NO)
Refund - ID (populated into a dropdown list from Retailers table), Name (Empty), Status (Empty)
Retailers is a table full of data, while Refund starts off as an empty table that gets filled in as a Refund Form is filled up. After creating a form based on the Refund table, how do I allow a user to select an ID from the dropdown list and populate the corresponding Name into the Name field and Status into the Status field?
What are the queries needed and how do I integrate this into the form?
I have tried the method found here - https://www.linkedin.com/pulse/autofill-form-microsoft-access-tim-miles
However, I have run into 2 problems:
1) The form does not appear in "Form View"; it is only viewable in layout view. I have read many links saying that the queries are read-only or that there are no records in the first place etc. The answers don't make sense.
2) If I bind the form (instead of a table) to a query this way, how do I save this new data into another table? My intention was to have the record saved in Refund table.
Sounds like Refund is your base table here. So, the query you want is:
SELECT a.[ID], b.[Name], c.[Status]
FROM Refund as a
Left Join Retailers as b
ON a.[ID] = b.[ID}
Left Join Registration as c
ON a.[ID] = c.[ID]
You'll need to make all 3 ID fields the Primary Keys in their respective tables. This should make the query updateable, and then you can use this query as the DatSource for your form.
You also have to make sure you set up the Relationships for all the tables. If you've never done it, it's easy to do and Microsoft gives you instructions here:
https://support.office.com/en-us/article/Create-a-relationship-40c998dd-4875-4da4-98c8-8ac8f109b85b
By setting up referential integrity in the relationships, you can save the data.

Change the displayed value in adf table

I am new working with ADF and Business component
I have a table with a columm with the department ID. This table is filled from another JSF page
I want to show the department name instead of the department Id
I have Business component with the view from my department table.
But I dont know how to show the department name instead de id in the adf table
My adf table is read only
you can create an LOV.Here you can select the type of attribute you need to display for the user externally(DNAME in your case) and type of value you need to store internally(DNO in your case) depending on the selected display value by the user.
Refer this link for LOV creation
http://techblogoracle.wordpress.com/2013/10/14/how-to-create-list-of-values-lov-in-oracle-adf/
Create a LOV in your VO for that property! Then you have two possibilities: 1- Reinsert your table in your page 2- Insert (re-insert) only the attribute that you need as a read-only column in that table!
To display the name of a department instead of the departmentId, create an LOV on the departmentId attribute in the view object that the ADF table is based on, pointing to the department view object.
To update your existing read-only table, remove the departmentId attribute from the JSF, and re-add it. Make sure that the new attribute is an "ADF select one choice." After the column has been added, select the select one choice drop down, and change the read-only attribute to true.
<af:selectOneChoice value="#{row.bindings.DepartmentId.inputValue}"
label="#{row.bindings.DepartmentId.label}"
required="#{bindings.Employees_VO1.hints.DepartmentId.mandatory}"
shortDesc="#{bindings.Employees_VO1.hints.DepartmentId.tooltip}"
id="soc1" readOnly="true">
If you run this page now, it should display the name of the department, instead of the id, while still being read-only.
How to show departmentName instead of departmentId using an LOV - ADF
If you're in the same taskflow or you share Data Controls and you don't want to change your VO to be based on two EOs, you can add a Transient attribute with the name, you will populate the value in the page that fills the data. Using LOVs it's too much of a headache. If the LOV list is big you will have performance issues that you introduce trying to solve a problem in a wrong way.
You can add referenced attributes to your VO.
So create a VO that is based on Emp and Dept together.
For example see the video here: https://blogs.oracle.com/shay/entry/whenvalidateitem_trigger_in_ad
use lov or use groovy Expression if number of values is not more than 2 or 3 values
usage : #{row.code eq 'A' ? 'Approved' : 'Rejected' }

soql getting data via a junction object

I have the following three custom objects:
Order__c
Design__c (has a lookup to Order and a lookup to Location, so the design ojbect is the junction object)
Location__c
On the order page layout I want to add a blank section that contains a VF page in order to display the Location records for all the design records for an order.
An order can have many designs and a design can have many locations. I need a way to group and display each design/locations in the VF page on the Order.
How can I build this query and display the results on the VF page?
I was trying a query like this: Select Location_r.Name, Location_r.Mockup From Design_c where Order_c = 'xxxxxxxxxxxxxx'
Also, is there a better way to display the results besides a VF page section in a related list?
Thanks for any help!
Regards.
First things, first. since design is related to the other 2 objects via lookup, it is not a junction object. junction objects are only when it's 2 parents have a master-detail relationship with the child.
I think what you're trying to achieve is to traverse a parent-child-parent relationship. You'll need to use subqueries for the last half. From the documentation- here you go: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm
Query **child-to-parent relationships**, which are often many-to-one. Specify these relationships directly in the SELECT, FROM, or WHERE clauses using the dot (.) operator.
For example:
SELECT Id, Name, Account.Name
FROM Contact
WHERE Account.Industry = 'media'
This query returns the ID and name for only the contacts whose related account industry is media, and for each contact returned, the account name.
Query **parent-to-child**, which are almost always one-to-many. Specify these relationships using a subquery (enclosed in parentheses), where the initial member of the FROM clause in the subquery is related to the initial member of the outer query FROM clause. Note that for subqueries, you should specify the plural name of the object as that is the name of the relationship for each object.
For example:
SELECT Name,
(
SELECT LastName
FROM Contacts
)
FROM Account
The query returns the name for all the accounts, and for each account, the last name of each contact.

Database design and large tables?

Are tables with lots of columns indicative of bad design? For example say I have the following table that stores user information and user settings:
[Users table]
userId
name
address
somesetting1
...
somesetting50
As the site requires more settings the table gets larger. In my mind this table is normalized, all the settings are dependent on the userId.
I have a thing against tables with lots of columns it just seems wrong to me, but then I remembered that you can select what data to return from the table, so If the table is large I could still break it into several different objects in code. For example
[User object]
[UserSetting object]
and return only the data to fill those objects.
Is the above common practice, or are their other techniques that deal with tables with lots of columns that are more suitable to use?
I think you should use multiple tables like this:
[Users table]
userId
name
address
[Settings table]
settingId
userId
settingKey
settingValue
The tables are related by the userId column which you can use to retrieve the settings for the user you need to.
I would say that it is bad table design. If a user doesn't have an entry for 47 of those 50 settings then you will have a large number of NULL's in the table which isn't good practice and will also slow down performance (NULL's have to be handled in a special way).
Instead, have the following:
USER TABLE
Id,
FirstName
LastName
etc
SETTINGS
Id,
SettingName
USER SETTINGS
Id,
SettingId,
UserId,
SettingValue
You then have a many to many join, and eliminate NULL's
first, don't put spaces in table names! all the [braces] will be a real pain!
if you have 50 columns how meaningful will all that data be for each user? will there be lots of nulls? Most data may not even apply to any given user. Think 1 to 1 tables, where you break down the "settings" into logical groups:
Users: --main table where most values will be stored
userId
name
address
somesetting1 ---please note that I'm using "somesetting1", don't
... --- name the columns like this, use meaningful names!!
somesetting5
UserWidgets --all widget settings for the user
userId
somesetting6
....
somesetting12
UserAccounting --all accounting settings for the user
userId
somesetting13
....
somesetting23
--etc..
you only need to have a Users row for each user, and then a row in each table where that data applies to the given user. I f a user doesn't have any widget settings then no row for that user. You can LEFT join each table as necessary to get all the settings as needed. Usually you only need to work on a sub set of settings based on which part of the application that is running, which means you won't need to join in all of the tables, just the one or tow that you need at that time.
You could consider an attributes table. As long as your indexes are good, then you wouldn't have too much of a performance issue:
[AttributeDef]
AttributeDefId int (primary key)
GroupKey varchar(50)
ItemKey varchar(50)
...
[AttributeVal]
AttributeValId int (primary key)
AttributeDefId int (FK -> AttributeDef.AttributeDefId)
UserId int (probably FK to users table?)
Val varchar(255)
...
basically you're "pivoting" your table with many columns into 2 tables with less columns. You can write views and table functions around this structure to give you data for a group of related items or just a specific item, etc. You could also add other things to the attribute definition table to indicate required data elements, restrictions on the data elements, etc.
What's your thought on this type of design?
Use several tables with matching indexes to get the best SELECT speed. Use the indexes as a way to relate the information between tables using a JOIN.

Resources