SSRS : How to make a data set field appear in the footer? - sql

I have a simple report with a dataset( Patient id, programid, name, address, phone). In my report footer, I am trying to write a condition where the footer value shouldn't show up for specific program ids. But the report footer doesn't display the dataset fields. How do I write this condition for report footer?

Headers and Footers can't display fields from your datasets because the dataset is out of scope for the header and footer - it wouldn't know which row to display the field for.
However, you can use aggregate functions to specify a scope and the row and field; for example, to show the ProgramId field from the first row of a dataset, you can use the First function, specifying the scope of the dataset:
=First(Fields!ProgramId.Value, "MyDataset")
So you could do something like this for the Visibility-Hidden property of the footer:
=IIF(InStr("10090,116,10094,10083", First(Fields!ProgramId.Value, "MyDataset")) > 0, True, False)

The footer and header sections of an SSRS report cannot have dataset items.
You can use the ReportItems to refer to a text box that is on your page.
Create a text box on your page with the value that you need then refer to that text box with the expression in your footer.
=IIF(ReportItems!TextBox1.Value = 4321, NOTHING, "Your Text Here")
MSDN: Report Items

we can use parameters in footers. you can have a parameter for the specific column and pass the value from code and use the parameter in footer expression like,
=Parameters!Param1.value

Page headers and footers can contain static content, but they are more commonly used to display varying content like page numbers or information about the contents of a page. To display variable data that is different on each page, you must use an expression.
If there is only one dataset defined in the report, you can add simple expressions such as [FieldName] to a page header or footer. Drag the field from the Report Data pane dataset field collection or the Built-in Fields collection to the page header or page footer. A text box with the appropriate expression is automatically added for you.
To calculate sums or other aggregates for values on the page, you can use aggregate expressions that specify ReportItems or the name of a dataset. The ReportItems collection is the collection of text boxes on each page after report rendering occurs. The dataset name must exist in the report definition.
For example, to hide or show a logo based on the value of the Customer Type in the dataset, create a Text Box called CustType in the report body, in that Text Box will be your CustomerType field. Then in the header or footer create another Text Box for your aggregate expression like so:
=ReportItems!CustType.Value = "Direct"

Related

How to mimic values in multi page SSRS Report

I need a lab report that has several pages. Each test has a unique reference number and I would like it to appear in the header according to what I have on the page. At the moment I only see one reference number and it remains unchanged after switching to another page. See attached image.
If possible, I would like to get rid of the SampleNo column so that its value is only in the header
The easiest way to do this is to reference the the textbox in your tablix that contains the "Sample No.".
Click the textbox that you have highlighted in the tablix, show the properties window (F4 in Visual Studio - can't remember in Report Builder, I think View/Properties).
Find the Name property of the textbox, this is often the name of the field it contains but not always.
In the example below the textbox name is 'oYear`
Next, set the expression in your header to be something like
=FIRST(ReportItems!oYear.Value)
Change oYear to whatever textbox name in your tablix is.
ReportItems refers to the rendered object name so here we just get the first on each page.
Here the first two pages from a small sample of data which groups by year.

PageNumber / TotalPages on group header in report .rdlc

I have a .rdlc report where I have no header (I have group headers)
I want to put the PageNumber on the group header.
If I use Globals!PageNumber I get this error:
The Value expression for the textrun 'Textbox12.Paragraphs[0].TextRuns[3]' refers to the global variable PageNumber or TotalPages. These global variables can be used only in the page header and page footer
Is there any way I could do this?
If there is no possibility to put this data on a group header...is there any possibility of overlap a header with the group header on a same line?
Global variables can't be used outside of the header/footer, as there is no relationship between the header/footer and body areas. Therefore, there is no easy and precise way to display the page number in the body area.
However, as suggested by user Raymond-Lee in the second link, you can try to calculate it yourself by dividing a given row number by the total number of rows per page (and adding one if the page number will always be the first row). Nonetheless, this would take a bit of effort.
First you need to have the Page Header/Footer showing, then you can add items to it. To show it, right click in the pale yellow area of the Layout view. Then select Page Header and/or Page Footer, this will create another section on your report where you can add items. Or, you can go to the Report menu option and enable the Page Header/Footer from there.
link

Report ,subreport pentaho

Iam using Pentaho report designer and we want to hide a subreport if there is no data .
I have tried to use this formula :
not(isemptydata())
in the visible expression but it does not seem to work .
So how to hide a subreport if no data .
Pentaho Report Designer elements have "attributes" and "style" sections. In style section there is a field "Visible". If you don't want to make the sub-report visible, it must be set to "false".
When want a function to disable it, the expression must return a "FALSE()" value.
You don't specify how the sub-report is generated and where is it placed (Details, Report Footer, etc), but, I'm gonna assume you have defined a function that has the count of rows for a group "TOTAL_ROWS" (and this is gonna be the field you are gonna compare), so, to hide the sub-report when 0 rows are present:
=IF([TOTAL_ROWS] = 0; FALSE(); TRUE())
"if the total number of rows is zero, return false, else return true".

Is it possible to colour a cell with value from data in Cognos BI?

Let me first be clear. I'm not asking about how I do conditional formatting in Cognos BI. If there were a simple Red/Amber/Green colour scheme, based upon value ranges then I could do that. If it were a static list of colours, which never changed, I could also do that.
What I am after is accessing a hex colour code that is stored in my database, and I want to use that colour as my table cell background colour. This is something I commonly do in SSRS reports, but cannot see a method for in Cognos BI.
Is this even possible?
You can do this via the HTML object in Cognos.
The HTML object can get its definition from one of the three main ways:
1) Hard-coded text
2) Data Item Value
3) Report Expression
Obviously the first method provides no way to dynamically set the value. I couldn't get the second one to work at all. I'm not yet sure why. However, I was able to use the third type to work to allow dynamic setting of a visual style.
For the solution we'll assume you have a data item called [Color] which pulls a string value from a database in the standard hex form that is used in CSS: #xxxxxx, e.g. #CCCCCC. For the purpose of this example we'll assume it is in query Query1. The following steps describe how to set it up.
1) Add an HTML item right above your list
2) Add another HTML item at the bottom of your list
3) In the top HTML item add a span tag with a unique id such as:
<span id="list">
4) In the bottom HTML item add a closing span tag
</span>
5) Add a third HTML item before all of the other HTML items
6) Set the 'Source Type' property of the HTML item to 'Report Expression'
7) In the Report Expression put the following code:
'<style>
#list td {
background-color: ' + [Query1].[Color] + '
}
</style>'
8) Select the Page object and set the Query property to Query1
9) Click on the Properties property. Check the Color column to give the page access to that query-sourced value.
Now you can dynamically set the column color based on a database provided value. We used the span to give us a way to isolate just the table cells we want to manipulate.
The technique isn't perfect. For instance, the header cells also get their background changed to the color in question, which may or may not be desirable. This is because Cognos doesn't use the th tag for headers but instead renders them as normal cells (td).
I know it's quite and old post but just for completeness I'll add the references to get this working in html, pdf and excel.
To get this working not only for html but also for pdf and excel use a rich text item instead of a html item.
You can use following code in a query item for instance:
<span style="display:block; background-color:' + [Query Subject].[Query Item] + '"> </span>
The query item must then contain a valid color (e.g. rgb(255,0,0)) etc. which is defined by your data source.
Dragging a rich text item in a list and changing it to data item value and selecting the query item will work.
By using the span it will work for excel too, however to make sure it follows the size of the upper object in the hierarchy (the list column or a table etc) you want the display:block style.
Instead of the space in between the > < you can use any other query item that you want to appear as text.

Vlookup for InfoPath 2010

I'm trying to develop a calculator type from in InfoPath where the user will be asked to end weight,height, and age. I will then take those values and use them to look up other values that are based on that number. For example if the column headers are Gender, Age, Height, L, M, and S. I want to find the 'L,M,S' values associated with that height. All values in the case are different. So if height were 45, L=-1, M=1, S=2; if height were 50, L= -2, M= 5, S=3.
In excel you a Vlookup with the syntax of :
Dim A as double
Dim Height as double
height = txtHeight.Value
A = Application.WorksheetFunction.VLookup(height, Range("C2:F652"), 2, False)
This would give you the "L" value for the row in which that height is located.
How can I do this in InfoPath? I have seen that are cascading queries you can do for dropdowns and comboboxes, but I want them to be able to type in a value, find a value on a SharePoint list based on that number and then return that number to another text box to use for my calculation.
If the values you want to look up are in a SharePoint list, then you need to create a data connection to that list. Make sure to include all the fields you need. Don't load the data connection at form load.
Let the user enter the height. Create a rule for the height field that fires when the field changes. Add an action that sets the query field for the secondary data source to the value of the height field, then query the data connection. Now the secondary data source contains the record with that height and the fields in the secondary data source contain the values. You can copy the values into text boxes on the canvas.
More details:
After you have set up a data connection to the Heights list, click the Heights field and add a rule by clicking New > Action.
Click the Add button and add an action to set a field's value.
Click the button next to the "Field" text box. If you don't see the top drop-down to select a different data source than the main data source, click the "Show Advanced View" link. Select the secondary data source for the Heights list, open the node for queryFields and the node below that and select the Height field.
Click the fx button next to the "Value" text box, then click "Insert Field or Group" and select the "height" field of the main data source.
OK out of all dialogs.
Add another rule to query for data.
Select the secondary data source to the Heights list.
Add another rule to set a field's value. For "Field" select the main data source field into which you want to copy the looked up value. For "Value" select the secondary data source and drill into the dataFields node until you see the field names. Select the desired field and OK out of all dialogs.
The rules panel should now look similar to this, but with your column names.
Test the form. Enter a valid height into the height field and click out of the field. The corresponding value from the height list will be written into the textbox. The screenshot shows the SharePoint list in the background with the item for heigt "66" highlighted. The value returned to the InfoPath text box "getV1" is from the "V1" field of the SharePoint list.
Hope that makes it clearer.