I have two datasets:
My main dataset (Students) looks like this:
Student Name | PID
Anakin SkyWalker | 1
Obi-Wan Kenobi | 2
And my second dataset (Awards) looks like this:
PID | Xtrnl_Award_Type | Xtrnl_Award_Date
1 | BS | 200912
2 | BA | 200605
2 | MS | 200905
What I want to get is this:
Student Name | Awards
Anakin SkyWalker | BS - 200912
Obi-Wan Kenobi | BA - 200605, MS - 200905
The LookupSet function can only return one field in the second dataset. Is there some other way I can get the results I want? The second dataset is on another server.
You can use an expression as the target Dataset field:
=Join(LookupSet(Fields!PID.Value
, Fields!PID.Value
, Fields!Xtrnl_Award_Type.Value & " - " & Fields!Xtrnl_Award_Date.Value
, "Awards"), ", ")
Works for me based on your data:
I just realized I can get what I wanted by adding a calculated field to my second data set that combined the two fields.
Related
I have two datasets:
My First dataset (Students) looks like this:
Student_Name| ID
Jack Luis | 1
Adam Bob | 2
And my second dataset (Exam) looks like this:
Student_ID | Exam | Note
1 | Java | 15
1 | Php | 14
2 | Java | 12
2 | Php | 13
I want to get this in the same Tablix:
Student Name | ID
Jack Luis | 1
Adam Bob | 2
Student_ID | Student Name | Exam | Note
1 |Jack Luis | Java | 15
1 |Jack Luis | Php | 14
2 |Adam Bob | Java | 12
2 |Adam Bob | Php | 13
Thank You Mr alejandro zuleta
but i want the result like this in the same Tablix (using groupin By Name)
Studant Name:Jack Luis
Exam | Note
Java | 15
Php | 14
Studant Name:Adam Bob
Exam | Note
Java | 12
Php | 13
I think this can be solved using LOOKUP function. LOOKUP function joins multiple dataset using a common field in the involved datasets.
Create a tablix and set the DataSetName property to your second dataset.
Drag and drop the fields to the columns you want to show. For the Student Name column use the following expression:
=Lookup(Fields!Student_id.Value,Fields!Student_id.Value,Fields!StudentName.Value,"DataSet21")
In the above expression replace DataSet21 by the actual name of your
first dataset.
It will preview something like this:
UPDATE: Grouping by a header row.
Add a tablix and set your second dataset in DataSetName property. Add Exam and Note fields to the corresponding columns.
Add a Parent Row Group.
In the Tablix group window select the Add group header checkbox and use the following expression:
=Lookup(Fields!Student_id.Value,
Fields!Student_id.Value,Fields!StudentName.Value,"DataSet21")
Delete the first column created by the previous grouping setting.
In the cell above Exam use the following expression:
="Student Name: " &
Lookup(Fields!Student_id.Value,Fields!Student_id.Value,Fields!StudentName.Value,"FirstDataSet")
Now select Exam and Note row and add a row above outside the group.
Type Exam and Note in the corresponding cell above [Exam] and [Note] fields.
Select the three cells in the first row, right click it and select Merge Cells.
It will preview something like this:
If you want to delete the first blank row, you can do it smoothly.
Let me know if this helps.
I am trying to get an Access report to identify if a text field (NH) does not match with the same ID. For example, ID 179 has two rows but each NH is different (12345 & 12346). I am trying to use DCount to count the IDs where the NH does not match if it is the same ID but I cannot figure it out.
Here is an example of my code:
This is supposed to get the ID's that match such as 179 and 179 and check the NH to see if the are the same and return a count if they are not.
CheckValue = DCount([ID], "vTestQuery", "[NH] <> '" & [NH] & "'" And "[ID] ='" & [ID] & "'")
This gives a value to Me.txtColor for a Conditional formatting I have set up if CheckValue has an actual value.
If (CheckValue > 0) Then
Me.txtColor = CheckValue
I also need this go through all the records in the report and get a count on each matching ID with different NHs so I can flag the NHs that are different.
Can someone let me know if I am even on the right track with this and if so a solution to my dilemma.
Thank you very much!
1st EDIT
Sample Data:
+-----+------------+------------+------------+-------------+
| ID | FullName | DateOfServ | AccountNum | NoteH |
+-----+------------+------------+------------+-------------+
| 179 | Test, Jane | 8/1/2015 | 458585 | AAA-1111111 |
| 180 | Test, Paul | 8/1/2015 | 458586 | AAA-2222222 |
| 181 | Test, John | 8/2/2015 | 458587 | AAA-3333333 |
| 214 | Test, Alex | 8/3/2015 | 458588 | AAA-4444444 |
| 214 | Test, Alex | 8/3/2015 | 458588 | AAA-4444445 |
| 215 | Test, Alex | 8/3/2015 | 458589 | AAA-5555555 |
| 215 | Test, Alex | 8/3/2015 | 458589 | AAA-5555555 |
+-----+------------+------------+------------+-------------+
So what I need the report to do is highlight or change text color for the IDs that match but have a different NH For example record 214 has two records with all the same exact data except for the NoteH and I need both those NoteH to be highlighted or the text changed. I have made the NoteH in question both bold. Let me know if this helps.
2nd EDIT
So the query worked for all duplicate IDs with duplicate NoteH, but it still only registers one ID if the NoteH is different. I added an IDCount to show how the query registers each 214 ID as different because of the different NoteH.
Here are the results:
+-----+------------+---------+
| ID | NoteCount | IDCount |
+-----+------------+---------+
| 214 | 1 | 1 |
+-----+------------+---------+
| 214 | 1 | 1 |
+-----+------------+---------+
| 212 | 2 | 2 |
+-----+------------+---------+
I need a way to have the report recognize that 214 is a duplicate field but the NoteH is not the same. It is really close to working everything else you suggested works great!!!
3rd EDIT
SELECT May.ID, Count(May.ID) AS IDCount, FROM May INNER JOIN
Count(CodeRyteCodingResults.[Note Handle]) AS NoteCount
CodeRyteCodingResults ON May.[Accession #] =
CodeRyteCodingResults.[Accession Number]
GROUP BY May.ID;
Use Aggregate Queries and Conditional Formatting
Create separate queries to get counts of unique notes per ID. It will look something like this (I'm using two queries):
UniqueNotesQuery
SELECT ID, NoteH
FROM BaseTable
GROUP BY ID, NoteH
NoteCountsQuery (this queries the first one)
SELECT ID, Count(NoteH) AS NoteCount
FROM UniqueNotesQuery
GROUP BY ID;
Then join this as part of your report query. It will look something like this:
SELECT BaseTable.*, NoteCountsQuery.NoteCount
FROM BaseTable INNER JOIN NoteCountsQuery
ON BaseTable.ID = NoteCountsQuery.ID
In your report, write a rule in the Conditional Formatting of the textboxes. Something like this:
[NoteCount] > 1
These queries above are just written from scratch, so they are untested, and you will need to flesh them out for your project.
References:
Office Support = GROUP BY Clause
Office Support - Conditional Formatting
How could I Split comma " , " seperated values in a cell to get value into adjacent different column with same column header in SSRS
I got a query table in SSRS report as follows
ProjectNo. | ProjectName | Client | Programmers |
01 | ave | rowan, Zica | A, B, C |
Now I want to display this in SSRS as Follows -
ProjectNo. | ProjectName | Client | Programmers |
01 | ave | rowan | Zica | A | B | C |
Any suggestion How could i achieve this only using SSRS ,and not modifying the query...
You would need to enter an Expression in each of the subsidiary cells which would use the Split function to return an array of substrings from your query column. The expression would be the same in each subsidiary cell other than the index of the element you want to return from the array.
Hope that helps - let me know if you would like an example.
I have a crosstab query which looks like:
It returns:
Response |
Agent1 |
Agent2 |
Agentt3
Response1 |
1 |
|
4
Response2 |
|
|
2
Response3 |
5 |
|
6
Total  
6 |
0 |
12
I have field 'Date' in my table, but when I add it in the crosstab query as 'Row Heading' (right next to Response column) and try to use it on order to filter the data, I got an error message: 'Cannot use the crosstab of a non-fixed column as a subquery'.
I was wondering if there is a way to add a filter option by date in the crosstab or how I can handle with that error above?
Also, one more thing: is there a way to hide any column in the query which doesn't have data in it's respective rows (For example: Agent2 column in the example above)?
Hey all, I am looking for a way to query my database table only once in order to add an item and also to check what last item count was so that i can use the next number.
strSQL = "SELECT * FROM productr"
After that code above, i add a few product values to a record like so:
ID | Product | Price | Description | Qty | DateSold | gcCode
--------------------------------------------------------------------------
5 | The Name 1 | 5.22 | Description 1 | 2 | 09/15/10 | na
6 | The Name 2 | 15.55 | Description 2 | 1 | 09/15/10 | 05648755
7 | The Name 3 | 1.10 | Description 3 | 1 | 09/15/10 | na
8 | The Name 4 | 0.24 | Description 4 | 21 | 09/15/10 | 658140
i need to count how many times it sees gcCode <> 'na' so that i can add a 1 so it will be unique. Currently i do not know how to do this without opening another database inside this one and doing something like this:
strSQL2 = "SELECT COUNT(gcCode) as gcCount FROM productr WHERE gcCode <> 'na'
But like i said above, i do not want to have to open another database query just to get a count.
Any help would be great! Thanks! :o)
There's no need to do everything in one query. If you're using InnoDB as a storage engine, you could wrap your COUNT query and your INSERT command in a single transaction to guarantee atomicity.
In addition, you should probably use NULL instead of na for fields with unknown or missing values.
They're two queries; one is a subset of the other which means getting what you want in a single query will be a hack I don't recommend:
SELECT p.*,
(SELECT COUNT(*)
FROM PRODUCTR
WHERE gccode != 'na') AS gcCount
FROM PRODUCTR p
This will return all the rows, as it did previously. But it will include an additional column, repeating the gcCount value for every row returned. It works, but it's redundant data...