Report with combined fields - reporting-services

I need to create report to render like image below:
So, for each question, I have several answers (4 or 5 answers), and every question have belonging image.
DATASET:
QuestionId QuestionName Image AnswerId AnswerText
1 Question 1 Image 1 Answer 11
1 Question 1 Image 1 Answer 12
1 Question 1 Image 1 Answer 13
1 Question 2 Image 1 Answer 21
1 Question 2 Image 1 Answer 22
1 Question 2 Image 1 Answer 23
1 Question 3 Image 1 Answer 31
1 Question 3 Image 1 Answer 32
1 Question 3 Image 1 Answer 33

To do this I have made the following assumption
You want each Question Text to appear as a new question with it's own associated answers
I would implement this using a List in SSRS
Add a new List item, and set it's DataSetName to your Dataset. (I have also set the BorderStyle to Solid in the example below)
Right click the Row Header, and select Row Group -> Group Properties, then Group on QuestionName
Within the body of the list item, draw a textbox for the Question name, and Create a Placeholder in it with the value =Fields!QuestionName.Value
Add a new image box, and set it to use the image =Fields!Image.Value
Finally add a new table, and set the data to be =Fields!AnswerText.Value. (You may also want to remove the header row)
The final layout should be something like this
And when run will render as
Hopefully this is the sort of thing you are after. If not then let us know to provide further assistance.

Related

Stacked bar chart in Qlik Sense: one bar for one field

I have this table:
Survey1:
LOAD * inline [
Respondent, AnswerToQuestion1, AnswerToQuestion2
resp1, 1, 1
resp2, 1, 2
resp3, 2, 1
resp4, 2, 1
resp5, 2, 3
resp6, 2, 1
resp7, 2, 1
resp8, 3, 2
resp9, 3, 2
];
I want to get a 100% stacked bar chart from this data. But it is difficult both, in Excel and in Qlick Sense... These programs do not accept that I would want to summarise one field/column into one bar.
My desired result should look similar to this:
Is there a way to do so in Qlik Sense?
I think you want to alter the way the data is modelled using unpivot/crosstable - which would create a table more like:
Respondent, Question, Answer
resp1, Question1, 1
resp1, Question2, 1
resp2, Question1, 1
resp2, Question2, 2
You could then make a stacked bar chart with 2 dimensions - Question & Answer with count(Answer)/count(TOTAL<Respondent>Answer) as your measure to give you a percentage. Note: I haven't tested that code - I'd start with a table with those 2 dimensions and count(Answer) as a measure - then check that count(TOTAL<Respondent>Answer) gives the total number of answers you'd expect.
In the script editor, assuming your table is called "Answers" this could be done with something like:
Answers_new:
crosstable(Question,Answer,1)
Load * resident Answers;
drop table Answers;
rename table Answers_new to Answers;

SSRS Matrix header repeat on each page (but outside of group to show every header from ds?)

I have a Matrix which I am trying to get a specific header to repeat on each page. To keep it simple it looks something like this:
| | Months |
|Division| |
| Name | Sales |
--- new page for each division ---
If I include the [Month] columns inside the Division group, it only shows the [Months] that have activity for that [Division]. For each page (per [Division]) I want to show all active [Months] within the dataset, not just that particular [Division].
So I tried creating a new row above, OUTSIDE of the [Division] group. This worked great for the first page, but I cannot get it to repeat on each page.
Is there a way to somehow set a Matrix row as a header for each instance/page of that tablix in the report?
Or
Show every [Month] from the dataset, inside of the [Division] group, and not just the active [Months] inside the [Division]?
Hopefully that makes sense, if not I will try my hardest to explain better.
Thanks in advance!!
I found the answer here:
https://msdn.microsoft.com/en-us/library/dd207045.aspx
Under "To Display a static row or column on multiple pages"
Thanks

SQL mass replace column value [duplicate]

This question already has answers here:
MySQL string replace
(6 answers)
Closed 8 years ago.
I have a database with a table name called mybb_users.
All users have a field name called avatar. Some users have their avatar set as
http://graph.facebook.com/userid/picture?width=250&height=250.
I want to mass-replace all the width and height of the people that use a facebook picture with this amount of width and height. I unfortunately don't know how to do this since the userid is random. Is there anyway I can mass replace width=250&height=250 to width=140&height=140 ?
Thank you!
you can do it with the REPLACE function:
UPDATE mybb_users
SET avatar = REPLACE(`avatar`, 'width=250&height=250', 'width=140&height=140')
WHERE avatar like '%graph.facebook%'
for further information have a look at: http://dev.mysql.com/doc/refman/5.6/en/string-functions.html#function_replace
You can update just the portion you want like this:
UPDATE mybb_users SET avatar = REPLACE(avatar, 'width=250&height=250', 'width=140&height=140')
this should replace all occurences of the 250 with 140

SSRS Get table last value from previous page

In Reporting Services imagine that i have a table with 1 column, that when is printed (2 pages) looks like this:
1st Page
Value
1
2
3
2nd Page
Value
4
5
6
What I need is that when it is printed looks like this:
1st Page
Value
1
2
3
2nd Page
Value
Last Value From Page 1: 3
4
5
6
Briefly what i want is that,in each page of the report (except in page 1) the first value is the last value from previous page...
Is that possible?
Thanks in advance...
There is built-in functionality to display row and column headers on multiple pages. This also tells you how to keep a static row or column visible while scrolling. Note the KeepWithGroup and RepeatOnNewPage properties.
If the rows you would like to repeat across pages are not group headers, you may have to make your own page group. This approach is not very pretty, but you could structure the data with flags to signal its own page breaks, and then manually include a repeat row after the page break. So the data set would look like:
Value PageFlag
1 1
2 1
3 1
3 2
4 2
5 2
6 2
You would add a grouping on PageFlag with a page break for each group.
On the Page Breaks tab, select Between each instance of a
group to add a page break between each instance of a group in the
table.
There is more detail on the KeepTogether property here. You can also read up on Pagination and Page Layout.

SSRS - How to build a simple multi-column report?

I am using SQL Server 2008 and I want to show 1 single field from a table in multiple columns in the report. Just like if I were to print labels. How can I achieve this?
Example:
Instead of printing:
Names Report
Andrea
Austin
Barbara
Bob
Bruno
Cathy
Chis
...
I want to print in columns (say 3 fixed columns):
Names Report
Andrea ---- Bruno ---- Darren
Austin ---- Cathy ---- Francis
Barbara ---- Chis ---- Gabriel
Bob ---- David ---- Gerald
....... ---- ....... ---- .......
Edit: If I run the report and click on "Print Layout" button, I can see multiple columns. Can I set this mode as default?
For Horizontal layout of labels...
One choice is to use the columns property on the report or body elements.
This doesn't always display correctly On reportviewer. I've noticed that even if it displays correctly on your IDE and when you export to PDF. In the report viewer it will display only one column. Also it snakes the labels top to bottom then left to right.
One choice is to use a matrix and group on every 3 rows (if you want 3 columns).
This one is a little complicated.
My solution of choice is to put 3 vertical lists on the page. put the same label in each list. Return the row number in your dataset. Then just filter each list on modulo 3
For example
Result set
RIndex Fname
1 abe
2 burt
3 fred
4 george
Filter expressions
list 1 -> =Fields!RIndex.Value mod 3 = =1
list 2 -> =Fields!RIndex.Value mod 3 = =2
list 3 -> =Fields!RIndex.Value mod 3 = =0
Result
Abe Burt Fred
George
The method I use is a bit similar as what Vern suggested but differs enough to make it worth mentioning here.
You can combine the ROW_NUMBER with the modulo (%) operator directly in the query to fabricate the column number in which the record should get displayed. Here's an example that generates one while taking a group into account:
declare #numberOfColumns int = 4;
select dpc.EnglishProductCategoryName, dp.ProductAlternateKey
, (ROW_NUMBER() OVER (
PARTITION BY dpc.EnglishProductCategoryName
ORDER BY dp.ProductAlternateKey) + #numberOfColumns - 1) % #numberOfColumns + 1
as DisplayColumn
from dbo.DimProduct dp
inner join dbo.DimProductSubcategory dps on dps.ProductSubcategoryKey = dp.ProductSubcategoryKey
inner join dbo.DimProductCategory dpc on dpc.ProductCategoryKey = dps.ProductCategoryKey;
To get this displayed I'm using nested tables which are then filtered on DisplayColumn.
Have a read through following article for all the details: Creating Multiple-Column Reports
Use the 'Report' menu in Visual Studio and select 'Report Properties'. You can set columns in the 'Layout' tab.
Try this msdn article about newsletter-style reports for more details: http://msdn.microsoft.com/en-us/library/ms159107.aspx
This method does have a limitation though so in some cases it might not be applicable:
Only PDF and Image renderers support
newsletter-style reports.
EDIT:
So one approach is to use multiple tablix with a filter that checks RowNumber and accordingly displays particular records in each table.
The other way is called Newsletter-style report (link). This formatting is retained only when report is exported as PDF or Image. It can be previewed only when you select 'Print Layout' on the Preview tab in Visual Studio. Here is an example:
Create a new report with the foll. dataset: SELECT ID,NAME FROM TABLENAME
Add a new table to the report and select the ID and Name as columns
Click on the tablix and press F4 to edit the tablix properties. In the properties window, change the Size - set the width to 2in
Click on the report area outside the report page boundary and press F4 to edit the report properties. In the properties window, change the Column value to 3, and column spacing value to 0.1
On the report scroll to the right hand side, you will notice that there are 2 new columns (so totally 3 columns on the report - because you selected 3 in step 4 above). Now click on the margin at the start of the column 2 and pull it further to the left to bring it as close to the column 1. This is only to reduce the need for huge page size.
Right click on the report area outside the report page boundary and select Report Properties. Change the Page Size - Set the width to 10in
Preview the report. Now select the 'Print Layout' tab to see the result. This formatting is retained only when report is exported as PDF or Image.
As noted in points 5 and 6 - since the report body flows into multiple columns, you must ensure that the page size is at-least equal to -> ([Original report body size times the number of columns] + all the column spacing values). Otherwise it will look messy.