Generate reports in birt using user input. When input is null, everything should be fetched otherwise corresponding data should be shown - birt

I have to create a birt report with user input parameters. It is something like when the para
meter is left blank it should fetch all values from a table otherwise when the user inputs the students roll no.,the corresponding data should be fetched. Can this be done through Birt report? If yes, then please suggest a way.
Thanks!

Yes, you can do that. If the parameter is optional you can't use the Dataset Parameter (with a ? in your query), because it will be null. Instead you have to modify your query using JavaScript.
Create a Report Parameter like usual, in this case 'stud_no'. Then add a comment in your SQL that you are reasonably sure is unique, I use something like --$stud_no$, wherever you want your clause inserted.
Then add a script like this to your Data Set, in beforeOpen:
if (params["stud_no"].value){
this.queryText = this.queryText.replace("--$stud_no$", "and stud_no = " + params["stud_no"]);
}
This replaces the comment with the clause when the parameter has a value. You can use regex in the search string, and then you can also insert it multiple places if you want.

Create your paremater using a like statement
where students_roll_no like ?
Create your report paramater using as a text box, with a defualt value of %
Because the percent '%' is the SQL wildcard, it returns all values. If the user enters a Student Roll number, it returns only that record. Additionally the user can enter 0500% and get all the records that begin 0500.

Related

How pull in fields value from created parameter

I created a parameter [GroupID] that is used to query several datasets in my SSRS report. It is using the field [GroupID] from my GroupList_Rolling12 dataset. An example of [GroupID] is 77610N. When 77610N is selected, all of my datasets are correctly 'filtering' for this [GroupID].
I now need to create a text box that returns the [GroupName] of [GroupID]. In other words, when 77610N is selected from my GroupID parameter, I want the [GroupName] that is associated with the selected GroupID parameter to display.
I'm still very new to SSRS and cannot figure this out. I tried creating the expression =First(Fields!GroupName.Value, "GroupList_Rolling12") but that did not work since it simply returns the first value from the query.
I also tried =First(Parameters!GroupID.Value(0)) but this also did not work
I also tried this expression =Lookup(Fields!GroupID.Value, Fields!GroupID.Value, Fields!GroupName.Value, "GroupList_Rolling12")
)
Can you please help?
You can reference the parameter label directly like this
=Parameters!GroupID.Label
There is no need to put the index on the end (=Parameters!GroupID.Label(0)) unless your parameter is multi-value, in which case it would select the first selected entry.

How to add rows to an Excel table inside a loop after the columns are mapped?

How to add rows to an Excel table inside a loop after the columns are mapped?
I tried the "Add rows to an Excel table" step, but I can't grab the values from Column1 and Column2 on the "Select" step above.
This should be easy, I guess, but I can't make it.
Thank you,
Your "Select" actions looks like it might be missing something, seems like it will add the whole item to "Column1" and duplicate that for "Column2". If your value is an array but it is not being recognized as so, you can use the "Parse JSON" action, or the json() expression you should be able to select the keys that you want to use for each column.
I might need more details to see the exact issue with your flow, but in the meantime try this:
Parse JSON action
Here the "Initialize variable" will be your blob storage result.
In the Parse JSON, add you blob storage value
In the "Select" action use the body output of the "Parse JSON" action
You should be able to select the specific values you want in your columns
json() expression
The parameter will be your blob storage. In my example is my string variable sown in the image.
Since the "Select" action returns an array as a result, the next step you should use is the "Apply to each" action
The new values mapped in the "Select" action should be available to be used here, if for any reason they are not (it is common for power automate to have issues like this) you can use an expression to get the value
items('Apply_to_each')?['columnName']
Note that the "Apply_to_each" inside "items" will be different if you rename this action.
Then, you'll have your Excel file with all the rows added to the table you selected.

SSRS Report Parameters Interactive

I have a report that requires 3 parameters, all 3 has q query to pre populate them using a dataset for each, so the under their properties the available values is selected with the query. Default were also set to use the same query. This work fine.
My problem is when the user of the report wanted to enter the values themselves rather than going into the list populated by the query. Users know the value that they wanted to enter so it's faster for them to enter rather than select. SSRS report seems not to give you the ability to enter if you have set the available values and default values for some reason. Is their a way to go around this please?
Many thanks.
There is one straight forward way to use comma separated multi value parameter rather than list where user enters input.
Below link explains in detail, but I am quite sure you do not want to stick to below solution.
https://www.mssqltips.com/sqlservertip/3479/how-to-use-a-multi-valued-comma-delimited-input-parameter-for-an-ssrs-report/
Another thing you could do is keep your multi value parameter as list as it is and create a text input parameter.
Now if user want to simply choose from list fair enough you will have to handle second parameter as null because user chose from list.
Then on your dataset check and apply filter as 2nd parameter value as not null.
Same goes if user does text input then multi value parameter as not null.

How do I set an SSRS Parameter that doesn't have a value to something else?

I have an SSRs Report with a parameter that gets information from SQL. If it hasn't found anything, at the moment it is just empty. Is there anyway to set it such that if it's empty it will return a different value, say "Please Extend Date Ranges" and disable the parameter?
If you using it to fill it using the SQL and using it for only internal purposes then there is option to make the parameter internal and it will be hidden and it will does not prompt the user.
Make a change to the stored procedure or query that populates the parameter. Include some logic so that if no results are returned by the query you are using now, it adds a row with the default label you want.
But no, you can't disable the parameter dynamically, I don't believe.

BIRT Issue while using MultiSelect List Box

I was supposed to use MultiSelect List Box (Dynamic one) where user can select multiple value (by holding Ctrl key) to see the report.
So while implementing I tried to fetch param value at BeforeOpen method and pass it to DataSet ,append it to where clause using IN operator.I got SQL error on screen. So when I print param value it was something like [Ljava.lang.Object;#26ba26ba] causing error in query. I thought I can't process that multiselect param value in script and pass it to query. So dropped that Idea.
Now I am using BIRT's inbuilt Filter functionality in Data set. What I was doing in SQL using script at Beforeopen Method now i am doing the same in dataset Filter. I used row["dataColumn"]IN param["param"].value and it is working fine. I am able to select one or multiple value from filter screen , execute report and getting proper result.
Now one more thing I need to implement is There should be Select All in filter list box so that instead of selecting any other value user can just select Select All and bring the report for all data. I am passing '%' against Select All. Since I am using IN operator so I am not able to get any data on Report.
I want to provide Select All functionality along with multiselection but not able to do that for above limitations . Alternatively I can use Ctrl+A to select all and it is working also I can do that but this is as per requirement that I need to implement.
I am using BIRT version="3.2.17"
ANY IDEA WILL BE APPRECIATED..Thanks In Advance..:)
Are you able to add a "Select All" option to your parameter choices? I have done this using a union with my parameter query and just adding a 'Select All' to my query results.
Normally what I'll do is add something to my query that will let me easily replace the parameters. Something like:
SELECT myStuff
FROM myTables
/**where**/
You can then modify your DataSet query in your beforeOpen statement.
Something along the lines of:
if(params["myParam"]!='Select All'){
this.queryText=this.queryText.replace("/**where**/","WHERE myStuff IN ('" + params["myParams"].join("','") + "')");
}
This is obviously very simplified, but you should be able to use some form of it to allow what you are asking.

Resources