Is there a workaround for evaluating Boolean variables within a Google Data Studio CASE statement? - boolean

I am creating a Google Data Studio report which has a Boolean (True/False) variable in it. Rather than the report displaying "TRUE" or "FALSE" I would like to display "Yes" (if true) and "-" (if false). I tried to create a new dimension variable in Data Studio leveraging a CASE statement; however, it apparently does not allow the use of the CASE statement when Boolean variables are in the expression.
I find it odd (actually a bit frustrating) Data Studio can handle a 'IS NULL" scenario and yet is unable to handle a Boolean scenario.
Is there a workaround for my situation which does NOT involve me having to create a new variable within the raw (input to Data Studio) data itself?
Thanks!

case when Boolean = TRUE then "yes" else "-" end
This works for me, give it a try!

Related

Play/Scala Template Block Statement HTML Output Syntax with Local Variable

Ok, I've been stuggling with this one for a while, and have spent a lot of time trying different things to do something that I have done very easily using PHP.
I am trying to iterate over a list while keeping track of a variable locally, while spitting out HTML attempting to populate a table.
Attempt #1:
#{
var curDate : Date = null
for(ind <- indicators){
if(curDate == null || !curDate.equals(ind.getFirstFound())){
curDate = ind.getFirstFound()
<tr><th colspan='5' class='day'>#(ind.getFirstFound())</th></tr>
<tr><th>Document ID</th><th>Value</th><th>Owner</th><th>Document Title / Comment</th></tr>
}
}
}
I attempt too user a scala block statement to allow me to keep curDate as a variable within the created scope. This block correctly maintains curDate state, but does not allow me to output anything to the DOM. I did not actually expect this to compile, due to my unescaped, randomly thrown in HTML, but it does. this loop simply places nothing on the DOM, although the decision structure is correctly executed on the server.
I tried escaping using #Html('...'), but that produced compile errors.
Attempt #2:
A lot of google searches led me to the "for comprehension":
#for(ind <- indicators; curDate = ind.getFirstFound()){
#if(curDate == null || !curDate.equals(ind.getFirstFound())){
#(curDate = ind.getFirstFound())
}
<tr><th colspan='5' class='day'>#(ind.getFirstFound())</th></tr>
<tr><th>Document ID</th><th>Value</th><th>Owner</th><th>Document Title / Comment</th></tr>
}
Without the if statement in this block, this is the closest I got to doing what I actually wanted, but apparently I am not allowed to reassign a non-reference type, which is why I was hoping attempt #1's reference declaration of curDate : Date = null would work. This attempt gets me the HTML on the page (again, if i remove the nested if statement) but doesn't get me the
My question is, how do i implement this intention? I am very painfully aware of my lack of Scala knowledge, which is being exacerbated by Play templating syntax. I am not sure what to do.
Thanks in advance!
Play's template language is very geared towards functional programming. It might be possible to achieve what you want to achieve using mutable state, but you'll probably be best going with the flow, and using a functional solution.
If you want to maintain state between iterations of a loop in functional programming, that can be done by doing a fold - you start with some state, and on each iteration, you get the previous state and the next element, and you then return the new state based on those two things.
So, looking at your first solution, it looks like what you're trying to do is only print an element out if it's date is different from the previous one, is that correct? Another way of putting this is you want to filter out all the elements that have a date that's the same date as the previous one. Expressing that in terms of a fold, we're going to fold the elements into a sequence (our initial state), and if the last element of the folded sequence has a different date to the current one, we add it, otherwise we ignore it.
Our fold looks like this:
indicators.foldLeft(Vector.empty[Indicator]) { (collected, next) =>
if (collected.lastOption.forall(_.getFirstFound != next.getFirstFound)) {
collected :+ next
} else {
collected
}
}
Just to explain the above, we're folding into a Vector because Vector has constant time append and last, List has n time. The forall will return true if there is no last element in collected, otherwise if there is, it will return true if the passed in lambda evaluates to true. And in Scala, == invokes .equals (after doing a null check), so you don't need to use .equals in Scala.
So, putting this in a template:
#for(ind <- indicators.foldLeft(Vector.empty[Indicator]) { (collected, next) =>
if (collected.lastOption.forall(_.getFirstFound != next.getFirstFound)) {
collected :+ next
} else {
collected
}
}){
...
}

Requesting member of node_element results in "undefined"

I'm using Opa for a school project in which there has to be some synchronization of a textfield between several users. The easy way to solve this, is to transmit the complete field whenever there is a change performed by one of the users. The better way is of course to only transmit the changes.
My idea was to use the caret position in the textfield. As a user types, one can get the last typed character based on the caret position (simply the character before the caret). A DOM element has an easy-to-use field for this called selectionStart. I have this small Javascript for this:
document.getElementById('content').selectionStart
which correctly returns 5 if the caret stands at the fifth character in the field. In Opa, I cannot use selectionStart on either a DOM or a dom_element so I thought I'd write a small plugin. The result is this:
##extern-type dom_element
##register jsGetCaretPosition: dom_element -> int
##args(node)
{
return node.selectionStart;
}
This compiles with the opp-builder without any problem and when I put this small line of code in my Opa script:
#pos = %%caret.jsGetCaretPosition%%(Dom.of_selection(Dom.select_id("content")));
that also compiles without problems. However, when I run the script, it always returns "undefined" and I have no idea what I'm doing wrong. I've looked in the API and Dom.of_selection(Dom.select_id("content")) looked like the correct way to get the corresponding dom_element typed data to give to the plugin. The fact that the plugin returns "undefined" seems to suggest that the selected element does not know the member "selectionStart" eventhough my testcode in Javascript suggest otherwise. Anyone can help?
In Opa dom_element are the results of jQuery selection (i.e. an array of dom nodes). So if I well understood your program you should write something like node[0].selectionStart instead of node.selectionStart.
Moreover you should take care of empty selection and selection which doesn't contains textarea node (without selectionStart property). Perhaps the right code is tmp == undefined ? -1 : tmp = node[0].selectionStart == undefined ? -1 : tmp

How does one pass null values to optional parameters in a Business Objects report using the Business Objects SDK?

I am building a web front end for accessing Business Objects reports using the Business Objects SDK for .NET. I have been able to hack my way through 95% of the business requirements with the sparse documentation and forum posts available online for the topic. My final roadblock centers on working with parameterized reports. Our business has situations in which a report has two parameters and the end user is only requried to populate one of them. It's easy enough to collect and cleanse this data, but no matter how I try to pass the null valued parameter to the reports, I get no data back. If both parameters are populated I DO get the expected data. When stepping through the code in Visual Studio I see that whenever BusinessObjects returns a null valued parameter it displays as an empty string (""). I have tried passing this as a parameter value and have also tried assigning the parameter a value of null. Neither of these options returns results once the report is scheduled and run. I have an example of my parameter assignment code below using each of the approaches that I've taken (We need to check for a string valued "null" as the user's have requested the ability to type "null" and have that passed to the report). None of these produce a report that contains data.
sVal.Value = param.ParameterValue != "null" ? param.ParameterValue : String.Empty;
sVal.Value = param.ParameterValue != "null" ? param.ParameterValue : "";
sVal.Value = param.ParameterValue != "null" ? param.ParameterValue : null;
Is there a specific value that the Enterprise Server uses to indicate null, such as dates are required to be wrapped in Date()?
Edit: The functionality I need to duplicate as seen in InfoView:
In Web Intelligence, by default all prompts are required and you must provide a value for it via the SDK. As of BusinessObjects XI R3 it is possible to actually configure the prompt in the report to be optional. This configuration is done by the report writer. When the prompt is optional then you can opt to not set the prompt value when working with the SDK.
An alternate way to have an optional prompt is to make the prompt "matches pattern" or if it is a date, figure out a default value. When the prompt is meant to be optional and is "in list" then you can set the value to be "%" which, while for a date, set the default value.

Database-field with false as value sent over XSD to Crystal Reports is evaluated as true

The application I work on is using a Crystal Reports to present reports to the user. I am using Visual 2010, but the report was created by a previous employee some years back using Visual2005.
The basic setup is that the client application make a request to the server that uses a xsd that define the data-set it sends back. Generally this work like expected, but I am having some problems with evaluating booleans.
A recent task consider of adding the dataset with a field name TrueWeekday that control if certain numbers should be printed out or not depending on if a date is a regular weekday or have some special local meaning that might affect the sampled data. The data is always used in some formulas so I can not exclude it from the dataset.
My first attempt involved defining the new field as a boolean and in the formula for the report I wrote
if {Header.TrueWeekday} then
CStr({Detail.Flow})
else
""
This had the result that no matter if the value in TrueWeekday was false or true the flow was presented. I debuged the server to verify that the variable indeed got the expected value so the problem happened in the Crystal Reports or in the transfer of data to Crystal Reports.
To solve this particular problem within the timeconstraints of the task I changed the field to the type string and wrote
if {Header.TrueWeekday} = "false" then
CStr({Detail.Flow})
else
""
This worked like a charm.
My problem here is not urgent since I have a working solution, but I am worried that this problem might create more subtle dataintrigity problems.
What might be the cause of this and how do I solve it?
Header.TrueWeekday is probably being passed as a string so that when you do if {Header.TrueWeekday} its testing a string as a boolean in which case if the string contains anything it evaluates to true and thus causes your problem
Work in a different project made me realize that .Net is probably serializing the boolean as the text string true/false. If then Crystal Reports does sloppy import and only check
input != 0
you will get the result that both true and false map to true after the transfer.

Can the Sequence of RecordSets in a Multiple RecordSet ADO.Net resultset be determined, controlled?

I am using code similar to this Support / KB article to return multiple recordsets to my C# program.
But I don't want C# code to be dependant on the physical sequence of the recordsets returned, in order to do it's job.
So my question is, "Is there a way to determine which set of records from a multiplerecordset resultset am I currently processing?"
I know I could probably decipher this indirectly by looking for a unique column name or something per resultset, but I think/hope there is a better way.
P.S. I am using Visual Studio 2008 Pro & SQL Server 2008 Express Edition.
No, because the SqlDataReader is forward only. As far as I know, the best you can do is open the reader with KeyInfo and inspect the schema data table created with the reader's GetSchemaTable method (or just inspect the fields, which is easier, but less reliable).
I spent a couple of days on this. I ended up just living with the physical order dependency. I heavily commented both the code method and the stored procedure with !!!IMPORTANT!!!, and included an #If...#End If to output the result sets when needed to validate the stored procedure output.
The following code snippet may help you.
Helpful Code
Dim fContainsNextResult As Boolean
Dim oReader As DbDataReader = Nothing
oReader = Me.SelectCommand.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.KeyInfo)
#If DEBUG_ignore Then
'load method of data table internally advances to the next result set
'therefore, must check to see if reader is closed instead of calling next result
Do
Dim oTable As New DataTable("Table")
oTable.Load(oReader)
oTable.WriteXml("C:\" + Environment.TickCount.ToString + ".xml")
oTable.Dispose()
Loop While oReader.IsClosed = False
'must re-open the connection
Me.SelectCommand.Connection.Open()
'reload data reader
oReader = Me.SelectCommand.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.KeyInfo)
#End If
Do
Dim oSchemaTable As DataTable = oReader.GetSchemaTable
'!!!IMPORTANT!!! PopulateTable expects the result sets in a specific order
' Therefore, if you suddenly start getting exceptions that only a novice would make
' the stored procedure has been changed!
PopulateTable(oReader, oDatabaseTable, _includeHiddenFields)
fContainsNextResult = oReader.NextResult
Loop While fContainsNextResult
Because you're explicitly stating in which order to execute the SQL statements the results will appear in that same order. In any case if you want to programmatically determine which recordset you're processing you still have to identify some columns in the result.