Count the whole column that matches your multiple criteria - countif

1 2 3
Attribute 1
Attribute 2
Attribute 3
1. Attribute 1 Attribute 2 Attribute 3 Grade
2. Yes Yes No 1
3. No No Yes 2
4. Yes No No 1
5. No Yes Yes 3
6. No No Yes 2
I want cell B2 to return the number of counted YES in Attribute1 under Grade 1. Is there a COUNTIF formula referencing to multiple columns with condition?

I suspect this is Excel, and the sparse matrix is the desired output format with 1 in B1, if so please try in B2 copied across and down to suit:
=COUNTIFS(INDIRECT($A2);"Yes";Grade;B$1)
Since the location of the data is not mentioned I have used named ranges for convenience and since spaces are not allowed in range names have used underlines instead, so for example, have changed Attribute 1 at the very top to Attribute_1.

Related

Shared foreign keys without duplication of entries?

Sorry for the beginner question.
I have an Outputs table:
ID
value
0
x
1
y
2
z
And an Inputs table that is linked to the Outputs through the outputsID:
ID
outputsID
name
0
0
A
1
1
B
2
1
C
3
2
B
4
2
C
Assuming that multiple outputs have at least one shared input (in this example outputID 1,3 and 2,4 are the same), is there a way to avoid the duplication of entries in my Inputs table (inputID 3 and 4)?
The 'normal' answer to your question is no. Rows 1 and 2 address output 1, and Rows 3 and 4 address output 2. They aren't duplicates and each reflect something distinct.
So if you are a beginner, I would say you shouldn't want to get rid of these rows.
That said, there are some more advanced techniques. For example, you could have the OutputsID column be an array with multiple values. This is harder, more complex, and non-standard.

Finding rows which match and blanks

I have a table of users and a table of electronic signatures - I want to be able to show for a given document who has signed and who has not.
Lets say we have employees:
EID Name
1 Bob
2 Tom
3 Fred
signatures:
EID Document Signature
1 1 Bob
1 2 Bob
1 3 Bob
2 1 Tom
3 2 Fred
My issue is that I can get this to work fine for document 4 - as no one has signed I can look where the document is null
However, if I look for document 2, for example, then I am currently getting employees missed off the list
For document 2 I would want to see
EID Signature
1 Bob
2
3 Fred
For document 4 I would want to see:
EID Signature
1
2
3
and for document 1:
EID Signature
1 Bob
2 Tom
3
The query I have tried to use is:
SELECT e.eid, s.signature
from employees e
left join signatures s on e.eid=s.eid
where s.document=? or s.document IS NULL group by e.eid
There are multiple issues:
Whenever using Left Join, any Where conditions on the right-side tables, should be put in the On clause. Otherwise, it will filter your result-set, even if there is no matching row (losing the purpose of Left Join)/
To compare null values, we use IS NULL. = null does not work. In this case, if we shift the conditions to On clause, we don't need to check for null values either.
Group By usage is invalid and really not required. When using Group By, only aggregated columns or the columns specified in Group By should come in Select. Refer: https://stackoverflow.com/a/41887524/2469308
Try the following:
SELECT e.eid, s.signature
FROM employees e
LEFT JOIN signatures s
ON e.eid=s.eid AND
s.document = ?

Combine multi rows in access - 1 field

I have data in multiple rows, and I need to combine data in similar columns and separate with a semi colon, to end up with one row with grouped by ID.
I have
ID Type
1 A
1 B
1 C
2 D
3 A
3 F
I want results to be
1 A;B;C
2 D
3 A;F
I have limited knowledge of access, but know this should be basic and easy. I appreciate assistance.

Is this pattern reconstitution or what is the name for this problem?

I've following problem and don't know the terminology to describe it and hence search for possible solutions.
I have a pivot table (matrix), eg each row and column have a named header. there is a defined set for rows and columns. Now let's assume that 10 rows are "combined" meaning each column is summed up to create a new "pattern".
What I would like is a way to determine alternative row combinations that lead to the same or similar "combined" pattern.
1 1 1
5 5 5
"Combined"
6 6 6
alternate row combination:
2 2 2
4 4 4
Suggestions? How is this problem called?
http://en.wikipedia.org/wiki/System_of_linear_equations#Matrix_equation
I just have to transpose above matrix to get Matrix A
[code]
1 5
1 5
1 5
[/code]
combined matrix is a vector b:
[code]
6
6
6
[/code]
and x would be just a vector full of 1.

Keeping some choices in the Table for the Field of Type Dropdown

i am having a Table named
Attributes
which has
id form_id label size sequence_no Type
1 1 Name 200 1 Text
2 1 Age 150 2 Number
3 1 Address 300 3 Textarea
4 1 Gender 200 4 Dropdown
I am having the doubt how can i keep the Choices of the Field of type "Dropdown" in the Table
Eg. For Gender the choices will Male , Female..
Please give me the suggestions...
You simply need a child table like this:
id value_id sequence_no label
4 100 1 Male
4 101 2 Female
Note where id = 4 is all the values for the #4 question.
Sounds like you're trying to build an automagic form that is built from a database?
I would suggest having that table be something like elements and have another table for options which links back to the original id
i.e.
options
id element_id value text
1 4 1 Male
2 4 2 Female
That way for specific types you will be know to look up the options.
You may want another field to specify if its a multiselect or perhaps you could make it another Type.
edit :
you can add another type to this table call dropdown_choice,
and add all the choices of this dropdown to this table,
need to keep in another field the master id of this dropdown choice.