SSRS: Grouping a List report with a chart - reporting-services

I am trying to create a list type report and can't seem to get the groupings correct. I am using VS 2017.
Here is the data set:
student_id full_name dob email note session_desc Percentage
6 Test Student 2008-07-24 Sample email Sample Note Main Session 1 59.5
6 Test Student 2008-07-24 Sample email Sample Note Main Session 2 61.5
6 Test Student 2008-07-24 Sample email Sample Note Main Session 3 66.9
6 Test Student 2008-07-24 Sample email Sample Note Main Session 4 64.9
I am trying to get the report to look like this (I cannot embed images):
At the top I have a rectangle with the parent group:
Test Student1
DOB: 1/1/2000
Email: test#gmail.com
And then inside another list or rectangle below, I want the detail records:
Main Session1 59.5% Line chart here from 0-100
Main Session2 61.5% Line chart here from 0-100
Main session3 66.9% Line chart here from 0-100
Main Session4 64.9% Line chart here from 0-100
This format would repeat for each student in the dataset. I am trying to use lists, but everything I have tried repeats the Student,dob,email info for the detail records.

I started with a larger version of your sample data so it included two students. Here's the dataset query I used to generate the data
note when I recorded the GIF I had the percentage column with the wrong number of decimals (decimal(5,2) instead of decimal(5,3)) hence why there are no decimals in the final output.
DECLARE #t TABLE(student_id int, full_name varchar(50), dob date, email varchar(100), note varchar(100), session_desc varchar(100), Percentage decimal(5,3))
INSERT INTO #t VALUES
(6, 'Test Student', '2008-07-24', 'Sample email', 'Sample Note', 'Main Session 1', 0.595),
(6, 'Test Student', '2008-07-24', 'Sample email', 'Sample Note', 'Main Session 2', 0.615),
(6, 'Test Student', '2008-07-24', 'Sample email', 'Sample Note', 'Main Session 3', 0.669),
(6, 'Test Student', '2008-07-24', 'Sample email', 'Sample Note', 'Main Session 4', 0.649),
(7, 'Test Student 2', '2008-07-01', 'Another email', 'Another Note', 'Main Session 1', 0.495),
(7, 'Test Student 2', '2008-07-01', 'Another email', 'Another Note', 'Main Session 2', 0.515),
(7, 'Test Student 2', '2008-07-01', 'Another email', 'Another Note', 'Main Session 3', 0.569),
(7, 'Test Student 2', '2008-07-01', 'Another email', 'Another Note', 'Main Session 4', 0.549)
SELECT * FROM #t
other than that I changed the percentages to be the correct decimal version (e.g. 0.5 = 50%), it's easier to work with and format in the report.
I didn't know what you meant by line chart so I added a databar to represent the percentage, I set the max value to 1 as our percentages are now all between 0 and 1
This clip starts after I added the dataset with the sample data and added a simple table. When you watch, the yellow highlights are left-clicks and the red highlights are right-clicks.
As you can seem even with a bit of clean up at the end the whole process take about 3 minutes to get the basic report running.
If you want to download the gif to watch it later or fullscreen, it's here
https://i.stack.imgur.com/22Fl2.gif
Hope this helps you in the future.

I figured it out. Instead of creating a parent row group from the detail group, I have to add a group expression to the detail group itself!
SSRS takes some getting used to - not the easiest to follow at first

Related

Import csv to database delimeter issues

The 3rd column in some row holds semi colon: test 1; test 2; test 3
INSERT INTO `test_table` VALUES ('21', 'test data', 'test 1; test 2; test 3', '', 'Other', 'test data', 'Free ', '')
What should be the setting for delimeter options in phpmyadmin to import in this situation?
My test.csv file is saved in the comma(,) separated format
Tried with column separated with: \t
Throws error as: Invalid column count in CSV input on line 1.
Ignoring insert record error, solved my problem without any delimeter changes.

How to get a macro do an action for each query record/row?

I'm building a room booking system in access, and I need some help with a macro regarding a query.
This is the form people will see when they come to book rooms:

This works fine.
What I've done is create a query that returns, depending on the day, what times a particular room is scheduled for.
This particular query is for Room 111 today. So here, it shows that today, Room 111 is unavailable for Periods 3,4 and 6.
I need to write a macro that looks at each of these lines and blanks out the relevant text box control on the form.
So it should end up looking like this:
I don't know if this is possible using Macros, or if I will need to use Visual Basic. I just need to get the macro/code to say:
"FOR Each Row, IF 111ScheduleCheck.TimeSlot="Period 1", THEN FORMAT 111_P1 TO Background=Black"
"FOR Each Row, IF 111ScheduleCheck.TimeSlot="Period 2", THEN FORMAT 111_P2 TO Background=Black"
etc etc
I've tried this however it doesn't work:
When I run it, I just get this error:
Can somebody help me do this?
Thanks,
Rowan :)
Consider bounding the form to the pivoted query below on a continuous/multiple item form where textboxes will serve as the Period fields with a Room field. Also, there might be room to normalize tables where all Rooms will use one Schedule table, thereby avoiding below union query.
SELECT dT.Room, dT.Day,
Max(IIF(dT.[Time Slot] = 'Period 1', 'Yes', NULL)) AS [Period 1],
Max(IIF(dT.[Time Slot] = 'Period 2', 'Yes', NULL)) AS [Period 2],
Max(IIF(dT.[Time Slot] = 'Period 3', 'Yes', NULL)) AS [Period 3],
Max(IIF(dT.[Time Slot] = 'Period 4', 'Yes', NULL)) AS [Period 4],
Max(IIF(dT.[Time Slot] = 'Period 5', 'Yes', NULL)) AS [Period 5],
Max(IIF(dT.[Time Slot] = 'Period 6', 'Yes', NULL)) AS [Period 6]
FROM
(SELECT 'Room 111' As Room, [Day], [Time Slot] FROM Schedule111
UNION SELECT 'Room 121' As Room, [Day], [Time Slot] FROM Schedule121
UNION SELECT 'Room 122' As Room, [Day], [Time Slot] FROM Schedule122
UNION SELECT 'Room 125' As Room, [Day], [Time Slot] FROM Schedule125) AS dT
GROUP BY dT.Room, dT.Day
And then conditionally format each of the six Period textboxes with background coloring:
[Field Value Is] equal to "Yes".
Finally, filter the form by the day value of the current page using form's OnCurrent trigger event. Be sure the date header control is a true Date formatted textbox:
DoCmd.ApplyFilter , "[Day]='" _
& WeekdayName(WeekDay(Forms!YourForm!YourDateControl,2)) &"'")

How to use an OUT paramter / read data with SELECT from table in a MySQL procedure

I am new in creating procedures in MySql and still learning it. So, I am stuck in creating procedures and need help. The question might seem basic but it will help me learn from basics.
Question:
I want to get the details of salary for each pilot when I specify his pilot_nbr.
Pilot Table consists of
pilot_nbr (primary key)
license_nbr
last_name
first_name
title
address
phone
office_nbr
contract_type
salary
manager_nbr
Sample Data
'701', '7111', 'Dark', 'Jack', '1st officer', '6 street', '6042233445', '789', 'PTE', '145000.00', NULL
'702', '7222', 'Mack', 'Bill', '1st officer', '7 street', '6043344556', '890', 'EMP', '155000.00', '701'
'703', '7333', 'Cheung', 'Charles', '2nd officer', '8street','6044455667','503','PTE','140000.00','701'
'704', '7444', 'Gordon', 'Greg', '1st officer', '9 street', '6045566778', '123', 'EMP', '125000.00', '701'
'705', '7555', 'Basso', 'Nicki', '2nd officer', '5 street', '6046677889', '223', 'EMP', '163000.00', '701'
'706', '7666', 'Vettel', 'Sebast', '1st officer', '5 street', '6046677800', '523', 'EMP', '199000.00','701'
'707', '7777', 'Hawke','Mike','2ndofficer','7street','6046677326',423','EMP','139000.00','701'
Here is what I did and got stuck:
DELIMITER //
CREATE PROCEDURE pilot_Salary_Procedure( IN pilot_Number INT(20), OUT pilot_Salary DECIMAL(10,2))
BEGIN
DECLARE pilot_NummberVariable INT(20);
SELECT pilot_nbr INTO pilot_NumberVariable
FROM pilot
WHERE pilot_nbr = pilot_Number;
END //
I would have done it that way (hoping that this is what you wanted):
DELIMITER //
CREATE PROCEDURE pilot_Salary_Procedure( IN pilot_Number INT(20), OUT pilot_Salary DECIMAL(10,2))
BEGIN
SELECT salary INTO pilot_Salary
FROM pilot
WHERE pilot_nbr = pilot_Number;
END //
You are then able to execute this procedure with
call pilot_Salary_Procedure(701, #salary);
The result then is stored in the session variable salary. You may read the value of this variable by issuing
select #salary;
and thus would get 145000 as result.
see also http://dev.mysql.com/doc/refman/5.7/en/call.html
NB: Be careful with your datatypes: Your notation above suggests that all your values in the table are string-like (for example CHAR or VARCHAR). Whilst this is perfectly okay for attributes like first_name, last_name or phone, it hazardous for other's like salary or even discrete values like the identifiers (pilot_nbr or manager_nbr). Especially salary should be a DECIMAL(15,2) or similar.

Column count doesn't match value count at row

INSERT INTO clnt_reports_01 (r_id, cl_no, cl_no, servi, size, vol,
deliver_point, port_, a_port, road, term, compet, speed,
rcomments, stage, meetrating, username, user_status, kids,
hobbies, comments)
VALUES (1, 123123, "test", "test", "test", "test",
"test", "test", "test", "test", 1, "test", "test",
3, 5, "test", "test", 5, "test", "test");
Getting the error -
Error Code: 1136. Column count doesn't match value count at row
Qoute strings with ' and make sure there is the same number of column in both cases (20):
INSERT INTO clnt_reports_01 (r_id,cl_no,servi,size,vol,deliver_point,port_,a_port,road,term,compet,speed,rcomments,stage,meetrating,username,user_status,kids,hobbies,comments)
VALUES (1, 123123, 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 1, 'test', 'test', 3, 5, 'test', 'test', 5, 'test', 'test');
" is treated as identifier (column name).
Also better use INSERT ... SELECT for readability:
INSERT INTO clnt_reports_01 (
r_id,
cl_no,
servi,
size,
vol,
deliver_point,
port_,
a_port,
road,
term,
compet,
speed,
rcomments,
stage,
meetrating,
username,
user_status,
kids,
hobbies,
comments)
SELECT
1 AS r_id,
123123 AS cl_no,
'test' AS servi,
'test' AS size,
'test' As vol,
'test' AS deliver_point,
'test' AS port_,
'test' AS a_port,
'test' AS road,
'test' AS term,
1 AS compet,
'test' AS speed,
'test' AS rcomments,
3 AS stage,
5 AS meetrating,
'test' AS username,
'test' AS user_status,
5 AS kids,
'test' AS hobbies,
'test' AS comments;
EDIT:
You have specified 21 columns and provided only 20 values so there is a mismatch.
cl_no seems to be repeated twice. Remove that.
You need to use single quotes instead of double for text
INSERT INTO clnt_reports_01 (
r_id,
cl_no,
servi,
size,
vol,
deliver_point,
port_,
a_port,
road,
term,
compet,
speed,
rcomments,
stage,
meetrating,
username,
user_status,
kids,
hobbies,
comments)
VALUES (1,
123123,
'test',
'test',
'test',
'test',
'test',
'test',
'test',
'test',
1,
'test',
'test',
3,
5,
'test',
'test',
5,
'test',
'test');
Insert query to specify 21 columns and passing value 20.
You are providing 20 values for 21 columns, maybe because you've listed the column cl_no twice. Even if you fix the column/value count issue, you'll get this error
Error Code : 1136
Column count doesn't match value count at row 1
well, your column count (21) does not match your value count (20) , you're trying to insert 20 things into 21 columns....
This is given away by the error that says
Error Code: 1136. Column count doesn't match value count at row
For this problem :
Error Code: 1136. Column count doesn't match value count at row
cl_no used twice, remove one this column.
You can use single quotes instead of double quotes.
Such as :
"test" -> 'test'
INSERT INTO fgm_pastor(
matriculePastor,
pastorName,
pastorSurname,
pastorBirthdayDate,
birthdayPlace,
pastorFathername,
pastorMothername,
pastorSexe,
pastorPhone,
pastorEmail,
dateConversion,
workBeforeBibleSchool,
rankProbation,
areaOfCalling,
nberYearArea,
nbreYearDistrict,
martialSituation,
nationality,
pastorAdresse,
photoProfil,
raisonIndispoMissionnaire,
id)
VALUES
(
'matriculetest3',
'nom test',
'prenomtest',
'2013-09-12',
'Dagobert',
'mon pere resr' ,
'ma mere test',
'M',
'phone test',
'pastorEmail test',
'2018-12-28',
'infomaticien',
'rank test',
'area test',
1,
3,
'Single test',
'Cameroun test',
'adresse test',
'phototest'
'RAS',
4
);

generate ID while Importing .sql file to database

I have a .sql file that I am importing into my database using phpmyadmin. Each time I have been going through the long list of values and changing the ID so it doesn't conflict with another entry. Since I don't care what the ID is, is there any way to have that auto generated?
Example:
INSERT INTO `my_column` (`id`, `valueone`, `valuetwo`) VALUES
(1, 'some value A', 'some value B'),(2, 'some value C', 'some value D'),(3, 'some value E', 'some value F');
So in the above code, I don't want to type in the "1", "2", and "3".
Can I just leave this blank for it to auto generate? Or is there a symbol that I add instead?
Thanks!
Add AUTO_INCREMENT to id column and remove it from the insert Statement:
INSERT INTO `my_column` ( `valueone`, `valuetwo`) VALUES
( 'some value A', 'some value B'),( 'some value C', 'some value D'),(...