SSRS - Adding "LIKE" filter criteria to report builder - sql-server

I want to add a LIKE filters with wildcards in SSRS report builder. I tried this using contains clause present in filter data section of report builder. I tried both '*' and '%', but of them failed.
I tried
MyFieldName contains 2451 - this succeds
MyFieldName contains 24* - this fails
MyFieldName contains 24% - this fails
From below link I feel that this is an old problem with no solution till yet.
http://connect.microsoft.com/SQLServer/feedback/details/202792/ssrs-adding-like-filter-criteria-to-report-builder
What do you guys suggest?
Thanks
Ravi Gupta

You could use the InStr function
=IIF(InStr(Fields!MyFieldName.Value, "2451"),TRUE,FALSE)

In SSRS we can't use Like. Instead of which you can use Contains.
IIF((MyFieldName).ToString().Contains("RequiredString"),"True","False)

In the report builder in Visual studio there is a Like and it works. Use a * as wildcard in your search string

Answering my own question, Below function worked for me:
IF(FIND(MyFieldName, "24") = 1, TRUE, FALSE)
This is just a partial answer as this will work for cases like (blabla*), but its not for cases like (bla*bla, blabla*). So anyone having a better idea is most welcome.
Got idea to do this from Darren's comment above.
Thanks
Ravi Gupta

The Report Builder does not support the LIKE operator. You must use CONTAINS;

This is pretty late to the party, but I worked out a solution for parameter filters for my dataset.
Adding a filter to my dataset with
Expression:
=IIF(InStr(Fields!AccountName.Value, Parameters!paramAccountName.Value) OR Parameters!paramAccountName.Value = "*", TRUE, FALSE)
Type
Boolean
Operator
=
Value
true
The parameter are defaulted to "*" so the report looks like it grabs everything by default.

I just came across this old thread and I'm curious why you can't use the like keyword, since I've always used it.
Did you try something like this?
Where (AccountName like '%' + #paramAccountName + '%' or #paramAccountName ='')

Related

SSRS adds new line when concatenating into a textbox

I'm stuck here. Everytime I concatenate SSRS textbox, the concatenation adds a new line. I use a Microsoft SQL 2013 database. Here is my expression that I use to concatenate.
=First(Fields!FirstName.Value, "DataSet1") & " " & First(Fields!LastName.Value, "DataSet1)
What happens is that there is a new line placed after the first name making the final output look like this.
FirstName
LastName
If anyone has any suggestions that would be great. I tried googling the problem and I couldn't find an answer. Please someone help.
Try using a variable under Report/Report Properties or even concat it on the query end...it may be easier
Perhaps you have leading/trailing spaces. Try using LTRIM or RTRIM.
=First(LTRIM(RTRIM(Fields!FirstName.Value)), "DataSet1")
& " " & First(LTRIM(RTRIM(Fields!LastName.Value)), "DataSet1)
I have found what was wrong. I had to select my expression (Expr). Then in the properties tab, I changed the Markup Type to HTML and that fixed my problem.
Thank you everyone for your time and effort.

peewee get_or_create and then save: error binding

Is there an easy way to update a field on a get of a get_or_create?
I have a class ItemCategory and I want to either create a new entry or get the already created entry and update a field (update_date).
What I do is:
item,created= ItemCategory.get_or_create(cat=cat_id,item=item_id)
if created == True:
print "created"
else:
item.update_date = datetime.now
item.somethingelse = 'aaa'
item.save()
This works for a while in my loop. But after 50-100 get/create it crashes:
peewee.InterfaceError: Error binding parameter 4 - probably unsupported type.
Maybe I should use upsert(), I tried but wasn't able to get anything working. Also it's not probably the best solution, since it makes a replace of the whole row instead of just a field.
I like peewee, it's very easy and fast to use, but I can't find many full examples and that's a pity
Newbie mistake
item.update_date = datetime.now()
I am not 100% sure this is the only answer though. I modified my code so many times that it might be also something else.
Regarding my question about create_or_update , I've done this:
try:
Item.create(...)
except IntegrityError:
Item.update(...)
peewee is really great, I wonder why no one ever asked for a create_or_update.

SETFILTER w WildCards Not Working as Expected

I have been trying to get Setfilter with wildcards working properly but i don't know why it isnt.
SETFILTER(Description,'*#%1*',"Assembly Header"."No.");
The filter does not work and does not display anything, probably because NAV is not interpreting %1 well
Found a solution, it is always better to make use of STRSUBSTNO function for wild cards concatenation
So, it do works fine
SETFILTER(Description,STRSUBSTNO('*#%1*',"Assembly Header"."No.");
:)
because it's working the other way around:
SETFILTER(Description,'%1','#*' + FORMAT(Assembly Header"."No.") + '*');
so [at][star]{search term}[star]
In NAV 2013R2 it's actually gave you an error message for '*#'
Cheers!
The only solution working for me in NAV 2018 was that of azatoth:
'*#....' not working
'#*....' working

What does the __default__ prefix mean in ng-inspector?

What exactly does the __default__ prefix mean in ng-inspector as shown below?
I am trying to access this value and I'm not quite sure how.
Thanks!
The extension certainly didn't add that prefix, if it shows up in ng-inspector, something else added that to your model.

Linq Querying for user search

I am trying to query from search box using list of data and the linq I used is:
data = (From k As BSPLib.ContactLib.Contact In data_org.Values Where k.stringdata Like "%" & Searchtxtbox.Text & "%" Select k.prime).ToList
But this is not working, I am getting no data at all. Data_org is a dictionary so I used the values; k.stringdata contains all the data that need to be searched. Searchtxtbox.text contains the user defined search item.
I Tried with sqlmethods through linq, but sqlmethods does not exist for me, I tried with with Imported namespace yet the code is not showing sql methods, could you please provide a workable query or just tell me where I have gone wrong. Thank you.
My Visual Basic is a bit rusty so forgive me if I have the syntax wrong:
One thing you could use is Contains which will be similar to "%Searchtxtbox.Text%"
and exactly the same if it is used with a DatabaseContext.
I know it is not the same as Like but if that doesn't work than likely something else is wrong and than I would like more code.
data = (From k As BSPLib.ContactLib.Contact In data_org.Values Where k.stringdata.Contains(Searchtxtbox.Text) Select k.prime).ToList
You can additionally use StartsWith and EndsWith for "Searchtxtbox.Text%" and "%Searchtxtbox.Text"
Also would I like to suggest to puth "%" & Searchtxtbox.Text & "%" between Parentheses for clarification, but that's all up to you.
The % wildcard character won't work here, remember this is .NET code, not SQL. You need something like this instead:
data = (
From k As BSPLib.ContactLib.Contact In data_org.Values
Where k.stringdata.Contains(Searchtxtbox.Text) Select k.prime).ToList

Resources