Using IF statement in Calcualated column
I have a list which has many different columns in, however, one is called Status. Now I would like a calculated column to have a calculation which says something like If Status = Approved, then return the title of the item in the list. Is this possible in
SharePoint 2013 office 365 version?
I thought something like this would work, but it doesn't.
=IF([Status]=Approved,"[Title]")
Thanks,
Nik
Hi Nik,
i think you're missing the second parameter (it should work without that but...).
This is the IF formula model: =IF(condition, true value, false value) so you need this in your formula:
=IF([Status]="Approved", [Title], "something else")
or
=IF([Status]="Approved"; [Title]; "something else")
The separator -> , it's not always the same, it depends on your regional settings, that's why i've used this one -> ;
Btw what type of field is Status?
Hope it helps.
Best regards.
Similar Messages
-
I am trying to learn HANA on my own.i have product id,product name,delivery date and Grossamount in my calculated view.i am trying to create calculated column where i need Grossamount in two columns based on delivery date.I have 2012 and 2013 as values for my delivery date.so i have created two column as grossamount_2012 and grossamount_2013.if i have delivery date as 4thdec,2012 i want the grossamount value to be in coloumn grossamount_2012 and the grossamount_2013 should be blank.i have written an expression like this
if("Deliverydate" <= longdate(2012-12-04),"Grossamount","0")
and it looks like this is wrong.i am getting the text Grossamount rather than values for that field in my output.so can anyone help me please?Hi chandra
i am trying to get the same result by using sql script and CE functions.i have written the following code
select A."PRODUCTID",
E."TEXT" as "PRODUCTNAME",
C."COUNTRY",
D."DELIVERYDATE",
Sum(D."GROSSAMOUNT") as "GROSSAMOUNT"
from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Products" as A
inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.BusinessPartner" as B
on A."SUPPLIERID" = B."PARTNERID"
inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses" as C
on B."ADDRESSID" = C."ADDRESSID"
inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.Purchase.Item" as D
on A."PRODUCTID" = D."PRODUCTID"
inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.Util.Texts" as E
on A."NAMEID" = E."TEXTID"
GROUP BY A."PRODUCTID",E."TEXT",C."COUNTRY",D."DELIVERYDATE";
this is working fine but i want to split the grossamount based on current year and last year.Any idea how to do this
In calculation view using script can we use if and case statements? -
How can I select columns from a table EMP, using Select statement?.
Hi Friends,
How can I select columns from a table EMP?.
I want to select columns of EMP table, using select statement.
Please reply me urgently.
ShahzadSomething like this:
scott@DBA> select empno,ename,job from emp;
EMPNO ENAME JOB
7369 SMITH CLERK
7499 ALLEN SALESMAN
7521 WARD SALESMAN
7566 JONES MANAGER
7654 MARTIN SALESMAN
7698 BLAKE MANAGER
7782 CLARK MANAGER
7788 SCOTT ANALYST
7839 KING PRESIDENT
7844 TURNER SALESMAN
7876 ADAMS CLERK
7900 JAMES CLERK
7902 FORD ANALYST
7934 MILLER CLERK
14 rows selected.Check the documentation:
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#sthref9697
Message was edited by:
Delfino Nunez -
Can we use return statement in procedure?
Can we use return statement in procedure or we can use more than one return statement in procedure?
HamidHelal wrote:
NOReally? Did you at least test it? You can use RETURN in procedure or in anonymous PL/SQL block. The only restriction is you can't specify return value:
SQL> begin
2 dbms_output.put_line('Before return');
3 return;
4 dbms_output.put_line('After return');
5 end;
6 /
Before return
PL/SQL procedure successfully completed.
SQL> create or replace
2 procedure p1
3 is
4 begin
5 dbms_output.put_line('Before return');
6 return;
7 dbms_output.put_line('After return');
8 end;
9 /
Procedure created.
SQL> exec p1;
Before return
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_output.put_line('Before return');
3 return 99;
4 dbms_output.put_line('After return');
5 end;
6 /
return 99;
ERROR at line 3:
ORA-06550: line 3, column 5:
PLS-00372: In a procedure, RETURN statement cannot contain an expression
ORA-06550: line 3, column 5:
PL/SQL: Statement ignored
SQL> create or replace
2 procedure p1
3 is
4 begin
5 dbms_output.put_line('Before return');
6 return 99;
7 dbms_output.put_line('After return');
8 end;
9 /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE P1:
LINE/COL ERROR
5/9 PL/SQL: Statement ignored
5/9 PLS-00372: In a procedure, RETURN statement cannot contain an
expression
SQL> SY. -
Using Select statement in IF condition?
hi all,
Can i use select statement in IF COndition in pl sql ?
eg like- if( select 1 from ASD) then
end if;There is no way to do any kind of select statement inside if conditions.
Why don't test simple cases like this first?
An example to show it.
SQL> begin
2 if exists (select 1 from dual) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if exists (select 1 from dual) then
ERRORE alla riga 2:
ORA-06550: line 2, column 5:
PLS-00204: function or pseudo-column 'EXISTS' may be used inside a SQL
statement only
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored
SQL> begin
2 if ( (select count(*) from dual) > 0 ) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if ( (select count(*) from dual) > 0 ) then
ERRORE alla riga 2:
ORA-06550: line 2, column 8:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + case mod new not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
<an alternativ
ORA-06550: line 2, column 33:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
. , @ ; for <an identifier>
<a double-quoted delimited-identifier> group having intersect
minus order partition start subpartition union where connect
SQL> begin
2 if ( 0 in (select count(*) from dual) ) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if ( 0 in (select count(*) from dual) ) then
ERRORE alla riga 2:
ORA-06550: line 2, column 12:
PLS-00405: subquery not allowed in this context
ORA-06550: line 2, column 2:
PL/SQL: Statement ignoredBye Alessandro -
Assigning values to 2 fields using sql statement
db11g , apex 4.0 and firefox 24 ,
hi all ,
i am trying to follow this tutorial to assign values to 2 items on a page using sql statement ,
and i am using the same sql statement the tutorial uses
select d.loc location, count(e.empno) num_employees from dept d, emp e where d.deptno = e.deptno(+) and d.deptno = :P3_DEPTNO group by d.loc -- btw , what does the "+" sign mean?
after the e.deptno in the where condition .
but i am facing this error
1 error has occurred
Wrong number of columns selected in the SQL query. See Help of attribute for details.
and it does not work with two columns in the select statement under any conditions , i tried to remove the group function and the group clause ,
it does not work unless i use only one column in the select statement ??
thanksPars
And how exactly is this rewrite of the sql statement resolving the OP's issue.
You are still using more than 1 column which will still result in the error message:
Wrong number of columns selected in the SQL query.
As mentioned in my earlier post APEX 4.0 (the version the OP is using) does not handle a sql statement with multiple columns for the dynamic action Set Value.
Which means the fastest and simplest solution is splitting up the dynamic action in multiple Set Value actions.
Using this plugin or upgrade to a newer apex version would also be a possibility.
Nicolette -
Need help in this sql query to use Case Statement
hi All,
I have the below query -
SELECT DISTINCT OFFC.PROV_ID
,OFFC.WK_DAY
,CASE
WHEN OFFC.WK_DAY ='MONDAY' THEN 1
WHEN OFFC.WK_DAY ='TUESDAY' THEN 2
WHEN OFFC.WK_DAY ='WEDNESDAY' THEN 3
WHEN OFFC.WK_DAY ='THURSDAY' THEN 4
WHEN OFFC.WK_DAY ='FRIDAY' THEN 5
WHEN OFFC.WK_DAY ='SATURDAY' THEN 6
WHEN OFFC.WK_DAY ='SUNDAY' THEN 7
END AS DOW
,OFFC.OFFC_OPENG_TIME
,OFFC.OFFC_CLSNG_TIME
FROM GGDD.PROV_OFFC_HR OFFC
WHERE OFFC.PROV_ID='0000600'
WITH UR;
this query is bringing results in 6 differnt rows with opening and closing time for each day separately. I want to generate the data in one row with each day having opening and closing time, so for 7 days, total 14 columns with opening and closing time. But i am not able to do that using case statement.
can somebody help me in achieving that.
thanks,
iamhereHi,
Welcome to the forum!
That's called a Pivot .
Instead of having 1CASE expression, have 14, one for the opening and one for the closing time each day, and do GROUP BY to combine them onto one row.
SELECT OFFC.PROV_ID
, MIN (CASE WHEN OFFC.WK_DAY ='MONDAY' THEN OFFC.OFFC_OPENG_TIME END) AS mon_opn
, MIN (CASE WHEN OFFC.WK_DAY ='MONDAY' THEN OFFC.OFFC_CLSNG_TIME END) AS mon_cls
, MIN (CASE WHEN OFFC.WK_DAY ='TUESDAY' THEN OFFC.OFFC_OPENG_TIME END) AS tue_opn
, MIN (CASE WHEN OFFC.WK_DAY ='TUESDAY' THEN OFFC.OFFC_CLSNG_TIME END) AS tue_cls
FROM GGDD.PROV_OFFC_HR OFFC
WHERE OFFC.PROV_ID = '0000600'
GROUP BY offc.prov_id
;This assumes there is (at most) only one row in the table for each distinct prov_id and weekday. If not, what do you want to do? Post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
The staement above works in Oracle 8.1 and up, but there's a better way (SELECT ... PIVOT) available in Oracle 11. What version are you using? (It's always a good idea to include this when you post a question.)
Edited by: Frank Kulash on Jan 6, 2011 8:22 PM -
Advantages of using prepared statement..... ?
can anyone please tell me that what r the advantages of using prepared statements.
for eg in case if statement object is executed inside a for loop where query is executed multiple times the sql query is compiled outside loop and therefore compilation is done only once. which makes sense
But if there the query is not executed multiple times then what is the real benifit of using prepared statement . because the statement object will be closed after executing the query.
and a new statement object will be created when other user access the same code.
please clearify my doubts
thanks
PankajOther advantages of using PreparedStatement:
1. It's easier to create SQL that looks like "Select This, That, TheOther from Something where ID=? and Usage=?" than to try to generate that with string concatenations.
2. You don't have to deal with escaping quote characters that happen to appear in strings you want to insert in your database.
3. PreparedStatements can do some things that Statement can't, such as updating very large text columns. -
Update query using FORALL statement
Hi ALL,
I have two tables Table: Mater_A(20 Cloumns) and Temp_A(20 Columns).
Both are almost identical. The Master_A is master table that has to be updated daily based on the temporary table Temp_A.
Everyday , i expect around 100000 records(same records with modified valus ) in Temp_A that has to be updated in Master_A. So i have to make the query as optimized as possible.
For this,I have created a cursor that has all records from table Temp_A.
Then i am using FORALL statement to update the data. But it throws exception something like that:
Error: PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND table of records
Error: PLS-00382: expression is of wrong type
It states that i have to create a separate type for each column that i want to update.
I have created procedure like this:
Open C_Temp_A;
Loop
Fetch C_Temp_A Bulk Collect into v_C_Temp_A limit 5000;
Exit When C_Temp_A%NOTFOUND;
Begin
ForAll i in v_C_Temp_A.first.. v_C_Temp_A.Last
Update Master_A mst Set mst.Column2= v_C_Temp_A(i).t_Column2,
mst.Column3= v_C_Temp_A(i).t_Column3,mst.Column4= v_C_Temp_A(i).t_Column4........to all columns
where mst.Column1= v_C_Temp_A(i).t_Column1;
End;
End Loop;
Close C_Temp_A;
Please help me to solve this or suggest me any other alternative to reduce the processing time.Why cant you use like :(Or I misread?)
SQL> select * from a;
ID C2
1 100
SQL> select * from b;
ID C2
1 1000
SQL> merge into b
2 using(select * from a) a
3 on (b.id = a.id)
4 when matched then
5 update
6 set b.c2 = a.c2;
1 row merged.
SQL> select * from b;
ID C2
1 100 -
FETCHING VALUES IN MULTI RECORD BLOCK FROM ANOTHER TABLE USING SELECT STATEMENT.
Hi,
I have one multi record block in which i want to fetch values
(more then one record) from another table using select statement
IN KEY NEXT ITEM.I am getting following error.
ORA-01422: exact fetch returns more than requested number of rows
Thanks in advance.In your case I see no reason to use non-database block and to try to populate it from a trigger with a query, instead of using the default forms functionality where you can associate the block and the fields with table, create where clause using bind variables and simply use execute_query() build-in to populate the block. The power of the forms is to use their build-in functionality to interact with the database.
Also, you can base your block on a query, not on a table and you dynamically change this query using set_block_property() build-in. You can use any dynamic queries (based on different data sources) and you simply need to control the column's data type, the number of the columns and their aliases. Something like creating inline views as a block data source.
However, you can replace the explicit cursor with implicit one like
go_block('non_db_block_name');
first_record();
FOR v_tab IN (SELECT *
FROM tab
WHERE col_name = :variable)
LOOP
:non_db_block_name.field1 := v_tab.col1;
:non_db_block_name.field2 := v_tab.col2;
next_record();
END LOOP; -
Sql proposed to use case statement
Hi All
Can anyone help me here
This code works fine,here inthe inner sub queries(b,c,d,e,f),i am getting the weekly counts of usage data from the table mf_wer_OBI_USAGE_reqq.
As this is hitting same table with the similar set of queries so i was adviced to use case statement by taking the wk_1...5 in variable and making the query better
I am unable to figure out how to proceed.
Appreciate your help here.
Thanks
create table mf_wer_OBI_USAGE_reqq_WK
as select x.user_name id,x.mon MONTH_COUNT,x.wk_1 WEEK1_COUNT,x.wk_2 WEEK2_COUNT,x.wk_3 WEEK3_COUNT,x.wk_4 WEEK4_COUNT,x.wk_5 WEEK5_COUNT,x.subject_area_name,
y.EMP_FIRST_NAME FIRSTNAME,y.EMP_LAST_NAME SURNAME,y.E_MAIL_ADDRESS USER_MAILID,y.ouc OUC
from (select a.user_name,a.mon,a.subject_area_name,b.wk_1,c.wk_2,d.wk_3,e.wk_4,f.wk_5
from (select user_name,sum(count_us_st) mon,subject_area_name from mf_wer_OBI_USAGE_reqq group by user_name,subject_area_name) a,
(select user_name,sum(count_us_st) wk_1,subject_area_name from mf_wer_OBI_USAGE_reqq where extract(day from start_dt) between 1 and 7
group by user_name,subject_area_name) b,
(select user_name,sum(count_us_st) wk_2,subject_area_name from mf_wer_OBI_USAGE_reqq where extract(day from start_dt) between 8 and 14
group by user_name,subject_area_name) c,
(select user_name,sum(count_us_st) wk_3,subject_area_name from mf_wer_OBI_USAGE_reqq where extract(day from start_dt) between 15 and 21
group by user_name,subject_area_name) d,
(select user_name,sum(count_us_st) wk_4,subject_area_name from mf_wer_OBI_USAGE_reqq where extract(day from start_dt) between 22 and 28
group by user_name,subject_area_name) e,
(select user_name,sum(count_us_st) wk_5,subject_area_name from mf_wer_OBI_USAGE_reqq where extract(day from start_dt) between 29 and 31
group by user_name,subject_area_name) f
where a.user_name=b.user_name(+)
and a.subject_area_name=b.subject_area_name(+)
and a.user_name=c.user_name(+)
and a.subject_area_name=c.subject_area_name(+)
and a.user_name=d.user_name(+)
and a.subject_area_name=d.subject_area_name(+)
and a.user_name=e.user_name(+)
and a.subject_area_name=e.subject_area_name(+)
and a.user_name=f.user_name(+)
and a.subject_area_name=f.subject_area_name(+)) x,
dm_employee y
where x.user_name=y.id and
y.active_flg='Y';Swas_fly wrote:
This code works fineIf it's fine, why try to fix it?
Post your table (only the relevant columns as a CREATE TABLE statement) and some sample data (INSERT into) and your required output.
Post your code between these tags: -
Hi
I have two tables
employee
empid empname empaddress valid
Employeedetails
empid empname manager
I would like to validate empname from both the tables using case statement and empid as join and update 'valid' column in employee table to y/n.
Please help me with the syntaxHi,
Depending on your requirements:
UPDATE employee e
SET valid = (
SELECT CASE
WHEN COUNT (*) = 0
THEN 'n'
ELSE 'y'
END
FROM employeedetails
WHERE empname = e.empname
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
If you're asking about a DML statement, such as UPDATE, the sample data will be the contents of the table(s) before the DML, and the results will be state of the changed table(s) when everything is finished.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
Using the States Example how can I set Selected to Maryland Without RowNumber
Let's use the states example for the sake of everyone having
the code in front of them. If I am returning a value from the
database that I am writting out to the application like this
<%out.write("STATE_NAME"); %>
how can I set the selected value to that without knowing what
the row number is, here is my try but I get a few error messages:
<option spry:if="{name} == '<%out.write("STATE_NAME");
%>'" value="{name}" selected
="selected">{name}</option>
<option spry:if="{name} != '<%out.write("STATE_NAME");
%>'" value="{name}" >{name}</option>
I get double the states and the following in the debug box:
Caught exception in Spry.Data.Region.prototype.processTokens
while evaluating: Alabama == Exception:[object Error]
Caught exception in Spry.Data.Region.prototype.processTokens
while evaluating: Alabama != '' Exception:[object Error]
This goes on for as many records as I have in the DB,
Please let me know how it could be done if it could be done?I believe what you guys are looking for is the
Set
Default Row Based on Specific Column sample that is on the
Spry
Samples Page.
The problem of using a spry:if="{name} ..." approach is that
it only makes sure the form select widget is set to what the server
thinks is the current row in the data set, but it doesn't actually
set the current row in the data set to reflect this, so the cities
select is out of sync cause it is defaulting to displaying the
cities for the first row in the states data set.
Checkout the sample I mentioned above, it will show you how
to set up an observer where you can query for the correct row
immediately after the data is loaded, and then set the current row
so that everything is as expected.
--== Kin ==-- -
Updating data without using update statement
Hi,
A quick question...
Can any table data could be updated without using update statement from backend.
Just wanted to make sure.
Thanks in advance.Hi,
What is your definition of Update?
Since your question is vague and you dont explain what exactly you mean.
here are my thoughts
1) A record can be deleted and isnerted with new values.Where the nes values have only few columns changed from previous ones.
2) I use pl/sql developer.If i need to update i can write select.. for update.Change the values (as in notepad)Commit.
This is infact a update but with nice UI
3) even your application can update data in your tables, if you code it and give correct privileges to the userRegards,
Bhushan -
Resultset from a batch select using prepared statement
Hi,
Is it possible to add results of batch execute of select statements and retrieve the result set ..
I am running select statement in a batch mode setting in value for a column.I add this to a prepared batch.
I would like to get the reults as a batch and spin through the result set like a r.next(). Is this possible ?
I have given the code below
sql = "select ordervalue , orderdate from discreet_orders "+
"where order_no = ? ";
dbObject.prepareStatement(sql);
dbObject.prepareStatement(sql);
for (int i=0; i < orderNoVect.size(); i++) {
dbObject.setString(1,(String)scnV.elementAt(i));
dbObject.addBatchPrepared();
r = dbObject.execPrepared();
dbObject.clearBatchPrepared();
I would like to do a r.getNext() process the values form the resultset.
Is this possible ? If not is there an other way to do it ?
Thanks
ArnoldOlek wrote:
hi
Is there a way do a batch update using prepared statement?
I don't want to insert every row in a single query...
regards,
OlekPossibly the confusion here stems from the existence of two addBatch methods in PreparedStatement.
addBatch(String sql)inherited from Statement adds a new query to the batch of SQL statements for the statement. However you don't want to use this with PreparedStatements Instead you want
addBatch()which adds the current set of parameters to the prepared statements batch of commands.
In this scenario you prepare your query (insert statement) and then call setXXX(x,y) for each parameter and then addBatch for each tuple. Then call executeBatch to execute all the queries based on your batched parameters.
If this didn't answer your question I don't know what your question is exactly. I would add that you probably want to set a "reasonable" size on your batches and break them into smaller batches as is reasonable. Mainly because the implementation of batched PreparedStatements widely varies depending on the database and driver, thus there are certainly scenarios where given enough batched parameters you could have various unpleasant things visited upon your program. Like terminal slowness, running out of memory, etc.
Maybe you are looking for
-
How to Cancel Succesful Processed Messages
Hi Experts, How to cancel the succesful processed messages which reached Integration Server and sender Adapter engine in XI. Thanks Venkat Anil
-
How to move Top-Level Navigation tabs from left to center side
Hi, Is there a way to modify the TLN tabs to display on the center side instead of the left? (as if it were a align = center in the code of table) I tried to change printLevel1Table and printLevel functions in toplevelnavigation.js.org file, but it n
-
i have a new i pod shuffle, and downladed music from both my i tunes and computer library but it keeps saying use i tunes to download, it doesnt seem to want to work is there something im doing wrong? Thanks.
-
Is the NW 2004s Java stack (WAS 7.0)available for download in SDN? Thanks.
-
Connecting to Windows Server displays 'alias could not be found' error...
We have a number of Macs all of which browse and connect to a shared Windows network... One Mac however, a 10.3.9 PoweMac G5, displays the 'alias could not be found' when trying to connect to one of the network servers (we have two, one is NT4, the o