Add map rule to predefined data style (refer to "value of this data item") - birt

in our reporting the value of data elements will be rewrited with "-" in the case of Null.
Can I put this mapping rule to the predefined style of the "data" element ? I tried it, but I don't know who to implement the later reference to "The_current_row_value". Has anyone a idea?
Thanks a lot.

Instead of trying to use an edit tool in the report, use SQL's isnull() to convert null values to whatever value you desire.
ISNULL (Transact-SQL)
If for some reason that does not appeal to you, use a computed column in your BIRT data set, and define the value with Java Script.

Related

Interactive switching of value fields in Quicksight Visuals

I'm sure this is a pretty noob question, but I am stuck. I have found a tutorial on how to use parameters to set switch between fields here: https://www.youtube.com/watch?app=desktop&v=Dk9NtZbH2Hw I was wondering if there is a way to do this with value fields, like say on a heat map visual, to be able to switch between revenue and cost via dropdown? I can not get a ifelse formula to work with these types for fields. Thank you in advance!
I dont't know much about the specifics of your data or the error, but similar to the video, you could create a parameter with manual values "Revenue" and "Cost" and set that as the dropdown control on the plot, then create a calculated field:
ifelse(${parameter} = "Revenue", {revenueFieldName}, ${parameter} = "Cost", {costFieldName}, "Some Default")
Then in the heatmap value field, use this new calculated field instead, and it should toggle based on the parameter.

Hibernate 4 : setting a default value if query returns null

I have a use case where i am mapping two tables to the same object.
In this object i have a string called source and I want to be able to set the table name or the database name to this variable.
Any ideas on how to achieve this?
I have thought about iterating over my list and manually setting it but this has the potential to waste a fair chunk of time.
I appreciate this is somewhat of an odd request so this may be the only way but am hoping for a solution that maps the source variable when hibernate is mapping everything else.
if i had understood correctly your issue , then your solution might be the MappedSuperClass , in which you must have an abstract class , which will have the common fields of the two tables and then you will extend that to the two entities you want , which will point to two different tables.
Check this link
You could try to achieve this with Load listener or Interceptors. In the listener/interceptor you can check what the data source is and populate the source field accordingly.
In the end i ended up using a formula to map my variable to a select statement which was sufficient for what i needed.

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.

iReport + XPath - Sum String Column

I'm building a report where I have a subreport. This subreport brings some data through XPath, this means it's everything strings from a XML. One of the columns of this subreport has some values, where I need do sum them and show in the end of the table.
I don't know how to put this to work. I've tried to create a variable with sum parameter, but it does not work.
Did anybody need this before?
Scenario:
I load a lot of values from a XPath query, e.g:
/something/something1/something2
This query returns some fields according to my needs. With them I build a table (in a subreport). The problem is: the last column (4), values are strings from XML.
iReport version: 3.0.0
Really thanks!
Solution:
What I needed? According to the original post, a column with strings read from a XML through XPath and a footer with the sum.
Result from column SUM
What to do? Create a variable where you'll keep your sum. After created, edit it. e.g:enter image description here
Fill variable expression with the format you need. Here I used
new BigDecimal($F{theFieldToSum});
Click ok. Now the variable is created, you must create a new TextField where you'll show your sum. Create it and edit it. Here I used the following format:
new java.text.DecimalFormat("#,##0.00").format($V{theVariableYouCreatedBefore})
Click "Apply" and that's all. Compile your report and now you'll have the expected result. For sure, you can do some adapt, but in general this is the process.

iterating over linq entity column

i need to insert a record with linq
i have a namevaluecollection with the data from a form post..
so started in the name=value&name2=value2 etc.. type format
thing is i need to inset all these values into the table, but of course the table fields are typed, and i need to type up the data before inserting it
i could of course explicitly do
linqtableobj.columnproperty = convert.toWhatever(value);
but i have many columns in the table, and the data coming back from the form, doesnt always contain all fields in the table
thought i could iterate over the linq objects columns, getting their datatype - to use to convert the appropriate value from the form data
fine all good, but then im still stuck with doing
linqtableobj.columnproterty = converted value
...if there is one for every column in the table
foreach(col in newlinqrowobj)
{
newlinqobj[col] = convert.changetype(namevaluecollection[col.name],col.datatype)
}
clearly i cant do that, but anything like that possible.. or
is it possible to loop around the columns for the new 'record' setting the values as i go.. and i guess grabbing the types at that point to do the conversion
stumped i am
thanks
nat
If you have some data type with a hundred different properties, and you want to copy those into a completely different data type with a hundred different properties, then somehow somewhere in your code you are going to have to define a hundred different "mapping" instructions. It doesn't matter what framework you are using, or whether the "mapping" instructions are lines of C# code, XML elements, lambda functions, proprietary "stuff", or whatever. There's no getting away from it.
Bearing that in mind, having one line of code per property looks to me like the fastest, simplest, most readable and maintainable solution.
If I understood your problem correctly, you could use reflection (or dynamic code generation if it is performance sensitive) to circumvent your typing problems
There is a preety good description of how to do something like this at codeproject.
Basically you get a PropertyInfo for the property you want to set (if it's not a property I think you would need dynamic code generation) and use it's setValue method (after calling the appropriate Convert.ChangeType of course). This will basicall circumvent the whole static typing, so there you are.

Resources