Hi i'm new to spotfire and wondering if I can ask of some help.
I am building an expression and I have a text field called HR Entity Name. I want to only return records that contain the word "Integrated" or "IP" in them.
Is there a function for this?
Thanks in advance
You can use ~= in the expression. ~= basically means contains. It can also take Regular Expressions and returns true or false which can be used for Data Limiting or building other columns. It is case sensitive. For example:
IF([HR Entity Name] ~= 'Integrated' or [HR Entity Name] ~= 'IP',TRUE,FALSE)
Related
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.
I'm pretty new to SSRS, may not be possible, but can I have a WHERE clause written in an expression?
I bassically have a dataset, but only want to assign the value to a text box based on the values in the dataset.
In linq, it'd look like:
ds.FirstOrDefault(x => x.IsHeader) but I can't work out the expression syntax. There is the First function, but that just gives me the first record - not filtered as its applied after the filters.
Anyone have any ideas - otherwise I need to split my dataset into multiple datasets, which is not ideal
Thanks in advance
You can do filtering in the First Expression like so:
=First(Fields!MiddleInitial.Value = "P")
=First(Fields!MiddleInitial.Value = Parameters!MiddleInitial.Value(0))
=First(Fields!MiddleInitial.Value,"AdventureWorks")
So for your example you'd have an expression that looks something like this (assuming your textbox is bound to ds):
=First(Fields!IsHeader.Value = True)
If the textbox isn't bound to ds you should be able to do this:
=First(Fields!IsHeader.Value = True, "ds")
it's best to do filtering in your SQL query.
You can set up a parameter in your dataset to properly display the data you want.
I need an urgent help from you guys, the thing i have a column which represent the full name of a user , now i want to split it into first and last name.
The format of the Full name is "World, hello", now the first name here is hello and last name is world.
I am using Derived Column(SSIS) and using Right Function for First Name and substring function for last name, but the result of these seems to be blank, this where even i am blank. :)
It's working for me. In general, you should provide more detail in your questions on places such as this to help others recreate and troubleshoot your issue. You did not specify whether we needed to address NULLs in this field nor do I know how you'd want to interpret it so there is room for improvement on this answer.
I started with a simple OLE DB Source and hard coded a query of "SELECT 'World, Hello' AS Name".
I created 2 Derived Column Tasks. The first one adds a column to Data Flow called FirstCommaPosition. The formula I used is FINDSTRING(Name,",", 1) If NAME is NULLable, then we will need to test for nullability prior to calling the FINDSTRING function. You'll then need to determine how you will want to store the split data in the case of NULLs. I would assume both first and last are should be NULLed but I don't know that.
There are two reasons for doing this in separate steps. The first is performance. As counter-intuitive as it sounds, doing less in a derived column results in better performance because the SSIS engine can better parallelize the operations. The other is more simple - I will need to use this value to make the first and last name split so it will be easier and less maintenance to reference a column than to copy paste a formula.
The second Derived Column is going to actually perform the split.
My FirstNameUnicode column uses this formula (FirstCommaPosition > 0) ? RTRIM(LTRIM(RIGHT(Name,FirstCommaPosition))) : "" That says "If we found a comma in the preceding step, then slice out everything from the comma's position to the end of the string and apply trim operations. If we didn't find a comma, then just return a blank string. The default string type for expressions will be the Unicode (DT_WSTR) so if that is not your need, you will need to cast the resultant into the correct string codepage (DT_STR)
My LastNameUnicode column uses this formula (FirstCommaPosition > 0) ? SUBSTRING(Name,1,FirstCommaPosition -1) : "" Similar logic as above except now I use the SUBSTRING operation instead of RIGHT. Users of the 2012 release of SSIS and beyond, rejoice fo you can use the LEFT function instead of SUBSTRING. Also note that you will need to back off 1 position to remove the comma.
I'm trying to determine a way to find all words in a database table called 'Word' that contain certain letters which is easy enough for single instances of letters, for example if I want to find all words that contain 'L' and 'I' I would use:
Words.Where(w => w.Word_value.IndexOf("I") > 0 && w.Word_value.IndexOf("L") > 0)
However, if I needed to find all words containing the letter 'I' and three instances of the letter 'L' (e.g. 'LILLY'), I am at a loss. Is there a way I can do a count of instances of a string within another?
Any help would be greatly appreciated.
Try this.
int count = Words.Length - Words.Replace("L", "").Length;
I would recommend using SQL Server's full text search capabilities.
Create a stored procedure that implements the functionality you require using full text search and then expose that using Linq to Sql or Linq to Entities.
Also see the CONTAINS predicate.
I'm tasked with adding an option to our search, which will return results where a given field doesn't begin with a letter of the alphabet. (The .StartsWith(letter) part wasn't so hard).
But I'm rather unsure about how to get the results that don't fall within the A-Z set, and equally hoping it generates some moderately efficient SQL underneath.
Any help appreciated - thanks.
In C# use the following construct, assuming db as a data context:
var query = from row in db.SomeTable
where !System.Data.Linq.SqlClient.SqlMethods.Like(row.SomeField, "[A-Z]%")
select row;
This is only supported in LINQ to SQL queries. All rules of the T-SQL LIKE operator apply.
You could also use less effective solution:
var query = from row in db.SomeTable
where row.SomeField[0] < 'A' || row.SomeField[0] > 'Z'
select row;
This gets translated into SUBSTRING, CAST, and UNICODE constructs.
Finally, you could use VB, where there appears to be a native support for the Like method.
Though SQL provides the ability to check a range of characters in a LIKE statement using bracket notation ([a-f]% for example), I haven't seen a linq to sql construct that supports this directly.
A couple thoughts:
First, if the result set is relatively small, you could do a .ToList() and filter in memory after the fact.
Alternatively, if you have the ability to change the data model, you could set up additional fields or tables to help index the data and improve the search.
--EDIT--
Made changes per Ruslan's comment below.
Well, I have no idea if this will work because I have never tried it and don't have a compiler nearby to try it, but the first thing I would try is
var query = from x in db.SomeTable
where x.SomeField != null &&
x.SomeField.Length >= 1 &&
x.SomeField.Substring(0, 1).All(c => !Char.IsLetter(c))
select x;
The possiblility exists that LINQ to SQL fails to convert this to SQL.