How to apply Like Operator in SSRS expression.
HI All,
I have SSRS report, in that i have 2 columns like Account_Code , Variance_Column.
i wants to write expression like
if Account_Code starts with 4 then i need to multiply variance_column * 1
if Account_Code starts with 5 ,6 then i need to multiply variance_column * -1
else Same values should appear.
Please do need full.
bala krishna
Hi bala,
After testing the issue in my environment, we can use InStr function to achieve your requirement. The following expression is for your reference:
=iif(InStr(Fields!Account_Code.Value,"4")=1,Fields!Variance_Column.Value*1,iif(InStr(Fields!Account_Code.Value,"5")=1 or InStr(Fields!Account_Code.Value,"6")=1 ,Fields!Variance_Column.Value*(-1),Fields!Account_Code.Value))
For more information about InStr function, please see:
http://msdn.microsoft.com/en-IN/library/ms157328.aspx#VisualBasicFunctions
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Similar Messages
-
How to use LIKE operator in plsql
Hi
I wanted to select certain rows using like operator in plsql(Input should be given by the user). I have given my experiment here .I couldn't get any result.
As per sql syntax while using LIKE operator we should give search criteria within single quote.where as in plsql if we give within single quote its takes as string so no output is comming.what is solution ? How to use like operator in plsql?
sql syntax
SQL>SELECT customer_name FROM customer_header
WHERE customer_name LIKE 'B%' ; customer_name
Bala murali
Babu
Basker
plsql syntax
PROCEDURE pro_custheader_like ( v_cname IN varchar2
,answer OUT type_refcur_customer) IS
BEGIN
OPEN answer FOR
SELECT customer_name FROM customer_header
WHERE customer_name LIKE ( ' v_cname ' );
END pro_custheader_like;
execution command
sql>variable answer refcursor;
sql>set serveroutput on
sql>exec package_name.pro_custheader_like( 'R',:answer);
plsql successfully completed
sql>print :answer
no row selected
by
balamuralikrishnan.splsql syntax
PROCEDURE pro_custheader_like ( v_cname IN
varchar2
,answer OUT
type_refcur_customer) IS
N
OPEN answer FOR
SELECT customer_name FROM customer_header
WHERE customer_name LIKE ( v_cname );
END pro_custheader_like;
Try it without any quotes. And, let us know your feedback.
Regards.
Satyaki De.
Message was edited by:
Satyaki_De -
How does this LIKE operator work ?
Values JOHN and KEITH have spaces in the string.
create table string_test ( test_str varchar2(15));
insert into string_test values ('JO HN');
insert into string_test values ('JOHN');
insert into string_test values ('RAM');
insert into string_test values ('KEITH ');
SQL> select * from string_test;
TEST_STR
JO HN
JOHN
RAM
KEITHFrom OTN , i found the query to find all string values which has a white space in it.
select * from string_test where test_str like '%' || chr(32) || '%';But, i don't understand how this works. Won't the percent sign in single quotes ('%') be considered a literal ?GarryB wrote:
Values JOHN and KEITH have spaces in the string.
create table string_test ( test_str varchar2(15));
insert into string_test values ('JO HN');
insert into string_test values ('JOHN');
insert into string_test values ('RAM');
insert into string_test values ('KEITH ');
SQL> select * from string_test;
TEST_STR
JO HN
JOHN
RAM
KEITHFrom OTN , i found the query to find all string values which has a white space in it.
select * from string_test where test_str like '%' || chr(32) || '%';But, i don't understand how this works. Won't the percent sign in single quotes ('%') be considered a literal ?No, because the "%" sign has special meaning to the LIKE operator. It's a wildcard meaning any characters. -
How tio use like operator in textitem to get the name
Oracle forms6i
Hai All
I have created an form to create an hierarchy list. I that I had an Text_item how can i use like operator to get the name to select. which trigger i need to use. when i select the name i need to get his employee code and other details
Thanks In Advance
Srikkanth.MA is the head of Dept 10 and three person are under A namelyHow will you know that B, C and D are under A is there any parent child relationship between Leader and Employee code? If yes, Then you can create the relationship between blocks no need to set where_clause programatically. So, relationship can be like...
leader_block.emp_code = emp_block.leader_code
AND leader_blokc.dep_code = emp_block.dep_codeSo, when you will query data in LEADER block it will show employees which are under LEADER which you queried in LEADER block.
Or if there is no relationship then how will you know that which employee under which leader?
b 002 10 1
c 003 10 1
d 004 10 1
When i enter the name of head corresponding other members in the department will need to display in the
Tabular format Or if you want to query the records only for department relation. Then as you said you create two blocks then create create the relationship using dep_code between those blocks.
like...
leader.dep_code = emp_block.dep_code-Ammad -
How to use like operator in IFTHENELSE (BODS)
Hi All,
I want to find the value of ' % ASSOC%' in the name and replace it to 'Assoc.' using ifthenelse.
Can any one help me. Is there any similar fuction as LIKE operator. Can we give LIKE in ifthen else condition.
Thanks in advanceHi ,
if you have data ASSOC1,ASSOC2
and you want Output like Assoc.1,Assoc.2.
In this condition it is not possible with ifthenelse function
it will return output as Assoc.
Example Source:
If we use if then else condition. Then it will replace all the Data to Assoc.
Or else if you want to replace ASSOC to Assoc. Then you can use Search_Replace also
it will generate a XML script
The expected output as follows in the below screen. As per your requirement you can you any one of this.
Regards,
Akhileshkiran. -
How to use like operator in loop
Hi I am trying to use like operation in loop condition. the code is as follows:
loop at lt_mara into l_mara where l_mara like '%XXX'.
endloop
when i have the like operator like above its giving me an error that i cannot use like operator. Is there anyway that i can use like operation in loop at condition,
Thanks in advanceusing the ranges with CP option we can do that..
Populate the ranges mentioned below..
data: r_matnr type range of matnr,
w_matnr like line of r_matnr.
w_matnr-low = '%XXX'.
w_matnr-sign = 'I'.
w_matnr-option = 'CP'.
append w_matnr to r_matnr.
loop at lt_mara into l_mara where matnr in r_matnr.
endloop
Regards
Vijay Babu Dudla -
How to use LIKE operator with PreparedStatement
Hi, I need to execute a query with the LIKE operator, but using a PreparedStatement. Can I do this, and if so what must my SQL look like with the wildcard characters '%' or '_'?
normal PS example: conn.prepareStatement("select * from mytable where name like ?");
If I try: conn.prepareStatement("select * from mytable where name like ?%");
I get: ORA-00911: invalid character
If I try: conn.prepareStatement("select * from mytable where name like '?%'");
I get: ORA-01006: bind variable does not exist
I must use a PreparedStatement, as my variable may contain illegal characters (like '), and using PreparedStatement.setString(1, var) will automatically escape it for me.
I could also use a normal Statement, but I need to escape my var ... is there a utility that will safely escape a String for an Oracle VARCHAR2??
Thanks in advance,
Stu MillerHmm, it seems you are right...
when my variable contains a '%' symbol, the PreparedStatement will NOT escape it, and thus it is treated like a wildcard. Therefore, I can just do
pstmt.setString(1, var+"%");
But, that may return more results than I'm asking for, as when 'var' contains a '%' symbol it is taken as a wildcard too.
I need each character in my variable to be taken literally, and only add a wildcard at the end. Basically, I need a STARTSWITH operator ;-)
It seems to me that escaping the sensitive characters in a String (which will differ depending on which operator is used), should be possible. I could write this, but I was hoping Oracle had already done it for me in some utility class. -
How to handle the #error in ssrs expression
hi
Please any one help me to resolve this #error ,
I have a calculated filed in that expression i given a if condition like below
data of column is coming like this 0 , 0.0
=IIF(Fields!Column1.Value=0,0,((Fields!Column2.Value - Fields!Column1.Value)/( Fields!Column1.Value)))
how to handle the #error
Please let me know any oneHi deepuk23,
According to your description, when you use the IIF() function in the report you got some error,right?
The issue can be caused by the column1 and column2 have different datatype, I assumed that one is integer and another is float, when the Column1 is 0 or null, because IIF() function always evaluates both the true part and the false part, even
though it returns only one of them, it will throw out the error.
To resolve the issue, you should use a nested IIF() function to avoid the zero-divisor in any rate like below:
=IIF(Fields!Column1.Value=0,0,((Fields!Column2.Value - Fields!Column1.Value)/(IIF(Fields!Column1.Value=0,1,Fields!Column1.Value))))
For more information, please refer to this article:
FAQ: Why does the “Attempted to divide by zero” error still happen?
If you still have any problem, please feel free to ask.
Regards,
Vicky Liu
Vicky Liu
TechNet Community Support -
How to use LIKE Operator with my query requriment
HI all,
I have a requirement as follows
EMPID ENAME JOB SAL
10 RAJ KAMAL MANAGER 25000
20 KAMAL RAJ NAYAK CLERK 4000
30 NARENDAR GUPTA ANALYST 20000
40 ASHUTOSH GUPTA DEVELOPER 10000
50 ASHUTOSH NAYAR PROGRAMMER 15000
i am searching enames such that i need to get the whole name even if i search with just a single LETTER/WORD immaterial of the order they exist in the name for which i need to get the whole name.(INFACT WORD comparision)
ex:
1) select * from emp where ename like '%ka%'
i am getting:
10 RAJ KAMAL MANAGER 25000
20 KAMAL RAJ NAYAK CLERK 4000
This is not what i need i need just word camparision not letters comparision let me tell you...
select * from emp where ename like '%amal%'
Even for this query ill get the same output.. this is not my option to go..
I need just word comparision with starting letter and immaterial of the word position in the name
If it is possible to do with query please let me know..
Thanking you
Narendar VishwanathamFull example:
SQL> ed
Wrote file afiedt.buf
1 with e as (select 10 as empid, 'RAJ KAMAL' as ename, 'MANAGER' as job, 25000 as sal from dual union all
2 select 20, 'KAMAL RAJ NAYAK', 'CLERK', 4000 from dual union all
3 select 30, 'NARENDAR GUPTA', 'ANALYST', 20000 from dual union all
4 select 40, 'ASHUTOSH GUPTA', 'DEVELOPER', 10000 from dual union all
5 select 50, 'ASHUTOSH NAYAR', 'PROGRAMMER', 15000 from dual)
6 -- END OF TEST DATA
7 select *
8 from e
9* where regexp_like(ename,'(^| )KA( |$)')
SQL> /
no rows selected
SQL> ed
Wrote file afiedt.buf
1 with e as (select 10 as empid, 'RAJ KAMAL' as ename, 'MANAGER' as job, 25000 as sal from dual union all
2 select 20, 'KAMAL RAJ NAYAK', 'CLERK', 4000 from dual union all
3 select 30, 'NARENDAR GUPTA', 'ANALYST', 20000 from dual union all
4 select 40, 'ASHUTOSH GUPTA', 'DEVELOPER', 10000 from dual union all
5 select 50, 'ASHUTOSH NAYAR', 'PROGRAMMER', 15000 from dual)
6 -- END OF TEST DATA
7 select *
8 from e
9* where regexp_like(ename,'(^| )KAMAL( |$)')
SQL> /
EMPID ENAME JOB SAL
10 RAJ KAMAL MANAGER 25000
20 KAMAL RAJ NAYAK CLERK 4000
SQL> -
SSRS Expression for Conditional Filtering using the "IN" operator
Hello,
I need to filter my dataset based on a parameter:
If Period= 1 then Week must be in (W1, W2, W3), Else Week must be in (W10, W20, W30)
I tried using the "IN" operator but don't know how to create the expression for the "Value" field. I tried the following:
iif(Parameters!Period.Value = 1,
"W1, W2, W3",
"W10, W20, W30")
But it doesn't work.
Expression: Week
Operator: IN
Value: ???
Any help would be highly appreciated!Hi,
Use split function.
See this expression: IIF(Parameters!Period.Value = 1, SPLIT("W1,W2,W3",","), SPLIT("W10,W20,W30",","))
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/8da78c9b-7f0c-42f1-a9c4-82f065f317c9/using-the-in-operator-in-ssrs-expressions
Thanks Shiven:) If Answer is Helpful, Please Vote -
Hi,
Can anyone tell me how to use OR in an SSRS expression?
I would like to set the BorderStyle Left (& Right) property to "None" for two rows so I need to
use an OR (6 or 9)
This is what I have so far:
=IIf(RowNumber(nothing)=6,"None","Default")Hi,
Try Below,
=Switch(RowNumber(nothing)=6 ,"None",RowNumber(nothing)=9,"None")
OR
=IIf(RowNumber(nothing)=6 OR RowNumber(nothing)=9,"None","Default")
OR
=IIf(RowNumber(nothing)=6,"NONE",IIf(RowNumber(nothing)=9,"NONE","Default"))
Thanks -
Like operator and byte[ ]
hello,
how to use Like operator with byte[ ]
byte[] buff= myString.getBytes("UTF-8");
String query="SELECT * FROM Person WHERE Firstname LIKE ? "
ps = getConnection().prepareStatement(query);
ps.setBytes(1, buff);
rset = ps.executeQuery(); thanksno effect
byte[] buff= myString.getBytes("UTF-8");
String query="SELECT * FROM Person WHERE Firstname
LIKE ? "
ps = getConnection().prepareStatement(query);
ps.setBytes(1, new String(buff));
rset = ps.executeQuery();
What a complete and utter bunch of crap.
You are back to not having wildcards again.
God knows what is in myString.
And of course you still haven't posted your result set processing code which if it is the same garbage as before will do you no good whatsoever.
Crap.
What exactly is the problem here? Another copy and past programmer in over their heads with a deadline looming or what? -
Like operator in for all entries
hi all,
may i know how to apply like for "for all entries"
where the first position is 9.
syntax is incorrect. hope can get help.
thanks
CONCATENATE itab-xx+0(1) '%' INTO v_kstar.
SELECT kstar txt20 INTO TABLE it_act
FROM aaa
FOR ALL ENTRIES IN itab
WHERE kstar like v_kstar AND
spras = sy-langu.in that case u have to call with in loop itself, may be there is another way also.
do v_times times
varying v_name
from dept-dept01
next dept-dept02.
concatenate p_rprctr '%' v_name into v_dep.
concatenate '%' v_name into v_dep.
select single mctxt into v_txt
from cskt
where cskt~spras = 'EN'
and cskt~kokrs = 'PEPS'
and cskt~kostl like v_dep
and cskt~datbi eq '99991231'.
concatenate v_txt '-' v_name into v_txt.
write: (47) v_txt centered no-gap ,
sy-vline no-gap .
hide v_name.
clear v_dep.
enddo.
its not a complete code , just a sample code.
Regards
Prabhu -
Hi All,
Quite simply I don't really understand two things.
1) How is the LIKE operator is working to return both columns.
2) When to use the LIKE operator and when to use the relation operator.
Thanks.
(CODE)
SELECT *
FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
TO_DATE ('1-Jan-2009') bb FROM DUAL
WHERE aa LIKE bb
--returns both columns
SELECT *
FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
TO_DATE ('1-Jan-2009') bb FROM DUAL
WHERE aa = bb
--returns nothing
(/CODE)Hi,
DaveyB wrote:
Hi All,
Quite simply I don't really understand two things.
1) How is the LIKE operator is working to return both columns.The WHERE clause (whether it contains LIKE or anything else) will only control the number of rows: every row will have the same numberr of columns.
2) When to use the LIKE operator and when to use the relation operator.Use LIKE when you want to use "wildcards" (% or _).
Use other operators (like =) when you don't have wildcards.
(CODE)
SELECT *
FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
TO_DATE ('1-Jan-2009') bb FROM DUAL
WHERE aa LIKE bb
--returns both columns
SELECT *
FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
TO_DATE ('1-Jan-2009') bb FROM DUAL
WHERE aa = bb
--returns nothing
(/CODE)It's great that you're trying to format your code! I wish everyione did that.
Use square brackets ([ and ]) if you want to use [CODE] and [/CODE] tags.
LIKE operates on strings. Don't use a DATE where a string is required. Do some experiments like the ones you tried just using strings, if you want to see how LIKE behaves. -
How Get last five quarters data using ssrs expression
Hi All,
i have an ssrs report where i have to get last five quarters data and also last five months data when i select quarterly/monthly parameter.....
is there any possibilty that we can get this using ssrs expression
any help please.........Hi Mr.SMK,
According to your description, there is an SSRS report, you want to create a parameter, when you select quarterly, data of last five quarters will be displayed. If you select monthly, data of last five months will be displayed. If that is the case, please
refer to the following steps:
1. In design surface, in Report Data pane, right-click Parameters and click Add Parameter.
2. Type parameter name and prompt, set Data Type to Date/Time.
3. Click Available Values in left pane, select Specify values.
4. Click Add button, in Label text box, type Quarterly, then click (fx) button and type the expression like below:
=DateAdd("q",-5,Today())
5. Click Add button, in Label text box, type Monthly, then click (fx) button and type the expression like below:
=DateAdd("m",-5,Today())
6. Right-click the dataset used to retrieve data for the report and open Dataset Properties dialog box.
7. Click Filters in left pane, click Add button, select Data from Expression drop down list, set Operator to >=, in Value text box, type [@ParameterName].
The following screenshots are for your reference:
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support
Maybe you are looking for
-
RAM modules on different generations of macbooks
hello, i have recently upgraded the RAM modules of my 2.16GHz macbook core 2 duo. so am left with 2 unused 512mb RAM modules, can i install them on my brother's first generation macbook core duo? thanks.
-
Want to show an information message in PA30 screen
Hi ABAP gurus, For Infotype9000,subtype RHUB(newly configured) ,I want to show an information message in PA30 initial screen for operations 'Create','Copy' and 'Delete'. For that , I have used a BADI (hrpad00infty) , written code in PBO method of
-
How to perform FT on XY Graph data?
Hello, I have my data in two 1D arrays (X and Y) and plotted in an XY Graph. I did not use a waveform because it was not a time signal, it was a spatial one with an uneven interval. Briefly, the experiment measured the output of an amplifier as the
-
Restoring the data from table after deletion
Hi, If I delete the data from the database (using delete command) , is there anyway to restore that data. I know it looks bit weird but I'm checking whether there is any technique in abap by which we can restore the data. Your help would be apprecia
-
Can anyone explain to me how to print a page of Thumbnails of the same photo?
Can anyone explain to me how to print a page of Thumbnails of the same picture, for wallet photos?