I have a SharePoint list with 5 options (questions). Each option has a dropdown with values 1-6. The user (employee of a company) needs to select an option, then select a value from the dropdown and hit Submit. The selected value is unique. In other words, if the user selects the value 1 for the first option, that value cannot be chosen again. Here's an example form -
Category Rank
------------------------------
1. Work/Life Balance 4
2. Compensation 2
3. Commute 3
4. Work 1
5. Development 5
After filling the form, the data looks likes this on the Sharepoint list -
Employee Manager Work/Life Compensation Commute Work Development
--------------------------------------------------------------------------------
1. Employee 1 Manager 1 2 4 3 1 5
2. Employee 2 Manager 3 1 3 4 5 2
3. Employee 3 Manager 1 5 4 2 3 1
4. Employee 4 Manager 2 4 1 5 2 3
I'm able to get the Y-axis (for Rank) on the report just fine. The X-axis needs to display each category grouped by each Manager. Here's a sample of how I want it to look like -
Each colored bar on the X-axis is a Manager. This is my first time with SSRS (2012) and I'm just not sure how to accomplish this. If this is not possible, will moving the data to a SQL table in a different layout help? Any help is greatly appreciated.
You could aggregate each employee's response into an average in your dataset (I'm assuming you know how to do this):
Averages (just pretend)
Manager Work/Life Compensation Commute Work Development
--------------------------------------------------------------------------------
1. Manager1 2 4 3 1 5
2. Manager3 1 3 4 5 2
3. Manager2 4 1 5 2 3
Then you can use the categories as you have, with the manager as the series field. Pretty sure that should achieve what you're looking for.
Related
I'm trying to join a few tables in MySQL. Our setup is a little unique so I try to explain as good as I can.
I have a table 'INVENTORY' that represents the current items on stock.
These items are stored in a table 'COMPONENT'
Components are being used in installations.
Every user can have multiple installations and the same component can be used in multiple installation as well.
To uniquely map a component to an installation, it can be assigned to a PRODUCT. a product as has a 1-1 relationship with an installation. A component is not directly related to an installation
To finally assign a product to a specific installation a mapping table COMPOMENT_PRODUCT is used.
Example:
A component is like a part, lets say a screw. This screw is used in a computer. The very same screw can be used on multiple computers. But each computer can only be used on one specific installation.
TABLE COMPOMENT_PRODUCT
COMPOMENT_ID PRODUCT_ID
1 1
1 2
2 1
2 2
So we have the components C1 and C2 relevant for two installations.
TABLE INVENTORY
COMPOMENT_ID INSTALLATION_ID ON_STOCK
1 1 5
1 2 2
What I want to achieve
Now, I want to retrieve the inventory state for all components. But, not every component has an inventory record. In these cases, the ON_STOCK value from the inventory shall be NULL
That means, for this example I'd expect the following results
COMPOMENT_ID PRODUCT_ID ON_STOCK
1 1 5
1 2 2
2 1 NULL
2 2 NULL
But executing this query:
SELECT DISTINCT
COMPONENT_PRODUCT.COMPONENT_ID,
COMPONENT_PRODUCT.PRODUCT_ID,
INVENTORY.ON_STOCK
FROM INVENTORY
RIGHT JOIN COMPONENT_PRODUCT ON COMPONENT_PRODUCT.COMPONENT_ID =
INVENTORY.COMPONENT_ID
returns the following resultset:
COMPONENT_ID PRODUCT_ID ON_STOCK
1 1 5
1 2 5
1 1 2
1 2 2
2 1 (null)
2 2 (null)
Now, my next thought was, "of course, this is how joins behave, okay I need to group the results". But the way SQL works, the aggregation is not entirely predictable. SO when I
GROUP BY COMPONENT_PRODUCT.COMPONENT_ID,COMPONENT_PRODUCT.PRODUCT_ID
I get this result:
COMPONENT_ID PRODUCT_ID ON_STOCK
1 1 5
1 2 5
2 1 (null)
2 2 (null)
I have prepared a Fiddle here: http://sqlfiddle.com/#!9/71ca87
What am I forgetting here? Thanks in advance for any pointers.
Try this query -
SELECT DISTINCT
COMPONENT_PRODUCT.COMPONENT_ID,
COMPONENT_PRODUCT.PRODUCT_ID,
INVENTORY.ON_STOCK
FROM INVENTORY
RIGHT JOIN COMPONENT_PRODUCT ON COMPONENT_PRODUCT.COMPONENT_ID =
INVENTORY.COMPONENT_ID
AND COMPONENT_PRODUCT.PRODUCT_ID = INVENTORY.INSTALLATION_ID
I am designing a mysql database and have come across these relations which will grow in the future.
Suppose Customer is tied to 2 different tables Policies and Options.
Each customer has multiple relationship with policies and likewise with options. Since I am keeping a details and history of the table as well every time I add a relation with customer, I will have to maintain another 2 tables. To calculate the price the customer owes, I will have to go thru customer_policies then customer_options and calculate the total price. Also the number of tables increases as the relationship increases.
If customer has a relation with policies it will have 2 tables -
customer_policies and customer_policies_details.
If customer has one more relation with options, it will add 3 more -
customer_options, and customer_option_history.
Like wise, it will keep on adding 2 more tables if there is one more
relation and the problem grows and grows.
I have tried 2 different options which I have mentioned below. I wanted to know what is the best way to solve this problem so that the table can be maintained as the relation grows.
Option 1:
customer_policies:
CustomerPolicyId CustomerId PolicyId Status
1 1 1 Active
2 1 2 Active
customer_policies_details:
CustomerPolicyDetailsId CustomerPolicyId Price
1 1 10
2 2 20
customer_options:
CustomerOptionId CustomerId OptionId Status
1 1 1 Active
2 1 2 Active
customer_options_details:
CustomerOptionDetailsId CustomerOptionId Price
1 1 10
2 2 20
Option 2:
Create a single table customer_selections and use Type and Id field instead like so:
customer_selections:
CustomerSelctionId CustomerId Type Id Status
1 1 Policy 1 Active
2 1 Policy 2 Active
3 1 Option 1 Active
4 1 Option 2 Active
customer_selection_details:
DetailsId CustomerSelctionId Price
1 1 10
2 2 20
3 3 10
4 4 20
To create a history of this I just have to create a customer_selections_details and keep track of all changes.
There should be better ways to solve this problem.
I'm building a e-Commerce platform (PHP + MySQL) and I want to add a attribute (feature) to products, the ability to specify (enable/disable) the selling status for specific city.
Here are simplified tables:
cities
id name
==========
1 Roma
2 Berlin
3 Paris
4 London
products
id name cities
==================
1 TV 1,2,4
2 Phone 1,3,4
3 Book 1,2,3,4
4 Guitar 3
In this simple example is easy to query (using FIND_IN_SET or LIKE) to check the availability of product for specific city.
This is OK for 4 city in this example or even 100 cities but will be practical for a large number of cities and for very large number of products?
For better "performance" or better database design should I add another table to table to JOIN in query (productid, cityid, status) ?
availability
id productid cityid status
=============================
1 1 1 1
2 1 2 1
3 1 4 1
4 2 1 1
5 2 3 1
6 2 4 1
7 3 1 1
8 3 2 1
9 3 3 1
10 3 4 1
11 4 3 1
For better "performance" or better database design should I add
another table
YES definitely you should create another table to hold that information likewise you posted rather storing in , separated list which is against Normalization concept. Also, there is no way you can gain better performance when you try to JOIN and find out the details pf products available in which cities.
At any point in time if you want to get back a comma separated list like 1,2,4 of values then you can do a GROUP BY productid and use GROUP_CONCAT(cityid) to get the same.
I need to filter a table in mysql but can't get past the beginning.
The table has 2 fields:
ID_house house_feature
1 1
1 2
1 4
1 5
2 1
2 3
2 4
3 1
3 2
3 3
I need to filter this table using the following parameters:
house feature = 1
AND
house feature = 2
AND
house feature = 3
So that I get all houses with the requested feature.
I already tried to create something similar to this:
SELECT *
FROM houses
WHERE
house_feature = 1
AND
house_feature = 2
AND
house_feature = 3
But it doesn't work as I expected.
Is there a way to get this result with MySQL?
It seems that I acn filter the table using only the OR operator but this way I can't get the right result.
Thanks in advance for any help.
tony
You can do so ,by matching the distinct count of features per house ,so the house with exactly these 3 features will be returned
SELECT *
FROM t
WHERE
house_feature IN(1 ,2,3)
group by ID_house
having count(distinct house_feature) = 3
Demo
I've been making an award system in ms access but trying to use the if statement for 2 distinct parameters, i.e. in one class top 3 students get a different amount from what the top 3 students of another class might get. All the data of all classes is in one table.
See:
Student ID Class ID Average Rank Awards
1111 Form4 77.79166667 2
1189 Form4 105 1
1222 Form4 73.41666667 3
1234 Form4 69.95833333 4
1235 Form 3 77.16666667 3
1236 Form 3 72.875 4
1258 Form 3 82.54166667 1
1333 Form 3 77.25 2
1367 Form 2 56.54545455 4
1445 Form 2 75.66666667 2
1447 Form 2 75.72727273 1
1465 Form 2 74.18181818 3
1523 Form 1 76.18181818 3
1542 Form 1 75.51515152 4
1552 Form 1 79.03030303 2
1555 Form 1 79.63636364 1
at the awards column when creating a query the build formula I use i.e. IIf([Rank]=1,1100) gives all student IDs ranked 1 an award of 1100 but I want only form 1 student IDs to get 1100 and the others ranked 1st with different award values please assist.
I think you want something like:
IIF([ClassID] <> "Form 1", IIf([Rank]=1,500), IIf([Rank]=1,1100))
Obviously, you will have to edit the award amount since you didn't specify what you were giving, but the logic should hold true.
If this gets a bit more complicated, you can write a function in VBA (in any code module in the 'modules' section), and use it in the query:
ExpressionName: evaluateAward(ClassID, Rank)
In the function, you can then use nested select case statements. This may be much better for readability.