Case function in OBIEE
How to implement the following query in obiee answers or RPD
SELECT SUM(CASE WHEN tag_type='ALARM' THEN COUNT(TAG_TYPE) END) AS ACTIVE,
SUM(CASE WHEN tag_type='INACTIVE' THEN COUNT(TAG_TYPE)END) AS INACTIVE,
SUM(COUNT(*) )AS "TOTAL TAGS"
from TAG_DIM
GROUP BY TAG_TYPE;
Please respond immediately.......
Products table, total rows 72, Hardware 2, Electronics 13.
Example 1:
Prod_category
Hardware -> case when PRODUCTS.PROD_CATEGORY='Hardware' then count( PRODUCTS.PROD_CATEGORY) else 0 end
Electronics -> case when PRODUCTS.PROD_CATEGORY='Electronics' then count( PRODUCTS.PROD_CATEGORY) else 0 end
Total -> sum(count(1))
Result:
Prod_category----Hardware----Electronics----Total
Electronics---------------0----------------13----------72
Hardware----------------2-----------------0-----------72
Peripherals
and Accessories--------0-----------------0-----------72
Photo---------------------0-----------------0-----------72
Software/Other--------0-----------------0-----------72
Example 2:
Hardware -> sum(case when PRODUCTS.PROD_CATEGORY='Hardware' then 1 else 0 end)
Electronics -> sum(case when PRODUCTS.PROD_CATEGORY='Electronics' then 1 else 0 end)
Total -> count(PRODUCTS.PROD_CATEGORY)
Result:
Hardware----Electronics----Total
2--------------------13-------------72
Regards
Goran
http://108obiee.blogspot.com
Similar Messages
-
Applying decode function in obiee 11g
DECODE(A.AC_CCY,'INR',DECODE(DRCR_IND,'D',-1,1)*A.LCY_AMOUNT,DECODE(DRCR_IND,'D',-1,1)*A.FCY_AMOUNT),
DECODE(DRCR_IND,'D',-1,1)*A.LCY_AMOUNT,
Can any one help me how to decode the above sql statement in obiee 11g.
Edited by: 925104 on Apr 3, 2012 12:48 AMyou can achieve it by using CASE WHEN condition END function in obiee. nested case also supported by obiee.
check the below link Decode Join Condition in OBIEE RPD
Thanks
Jay.
Edited by: Jay on Apr 3, 2012 12:56 PM -
Converting Decode function in OBIEE
Hi Guru's
we are converting some BO reports to OBIEE and need to convert Decode function
Below is the Decode function they are using:
Decode ( sign(nvl(BOOKINGS_DATA_UDTC.qty_shipped,0)), 0,decode(BOOKINGS_DATA_UDTC.DELIVERY_NUMBER, 0,decode(BOOKINGS_DATA_UDTC.Schd_Ship_date_fk,to_date('1/1/1990','mm/dd/yyyy'),'Next Month Backlog',decode(sign(nvl(BOOKINGS_DATA_UDTC.Schd_Ship_date_fk, '01-JAN-90') -PAR.PAR_DATE), 1, 'Next Month Backlog', 'Current month will ship')) ,'Awaiting for collection') ,'MTD Shipped')
i have tried converting into case :
case when sign(IFNULL("BOOKINGS_DATA_UDTC"."Qty Shipped",0)) = 0 then (case when "BOOKINGS_DATA_UDTC"."Delivery Number" = 0 then (case when "BOOKINGS_DATA_UDTC"."SCHD_SHIP_DATE_FK" = '01-JAN-1990' then 'Next Month Backlog' else (case when Timestampdiff(SQL_TSI_DAY, cast('@{ParDate}{28-DEC-2012}' as Date),(case when "BOOKINGS_DATA_UDTC"."SCHD_SHIP_DATE_FK" IS NULL then CAst('01-JAN-1990' as DATE) else "BOOKINGS_DATA_UDTC"."SCHD_SHIP_DATE_FK" end)) > 1 then 'Next Month Backlog' else 'Current Month Will Ship' end) end) else 'Awaiting For Collection' end) else 'MTD Shipped' end
But it is not workign as expected.
Can some one please help me with this.
Thanks,you can achieve it by using CASE WHEN condition END function in obiee. nested case also supported by obiee.
check the below link Decode Join Condition in OBIEE RPD
Thanks
Jay.
Edited by: Jay on Apr 3, 2012 12:56 PM -
Issues with integrating Java script functions in OBIEE 11G
Hello experts..
I am trying to integrate some Javascript functions in my OBIEE 11G Dashboard..
I have modified the original common.js file and renamed it as insight_common.js in the following directory (backed up the original file of course)
OBIEE 11G Folder/user_projects/domains/bifoundation_domain/servers/bi_server1/tmp/_WL_user/analytics_11.1.1/7dezjl/war/res/b_mozilla/insight_common.js
In my dashboard, I have a dashboard object as text component where I have checked 'Contains HTML Markup'. I have written the following code:
hello
<script src="/res/b_mozilla/insight_common.js" type="text/javascript"></script>
<script type="text/javascript">
sayHi();
</script>
However, when I launch the dashboard, it is not working.
In the Google Chrome browser as I inspected the element to investigate the reason, I am getting the following error under 'console'
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/res/b_mozilla/insight_common.js
Uncaught ReferenceError: sayHi is not defined saw.dll:611
It seems that OBIEE is not recognizing the new file that I made..
Is there a way around this?
ThanksSrini
I don't have backgrounds in coding, so a lot of what I wrote came from my own researching...
Now I have tried your latest suggestions again as the below:
1.<script type="text/javascript" src="res/b_mozilla/insight_common.js">
sayHi();
</script>
and
2.
<script type="text/javascript" src="res/test.js"></script> ----- in my case: <script type="text/javascript" src="res/b_mozilla/is_common,js"></script>
Now both codes this time do not yield any outputs when launching the dashboard. The section is blank and the preview of the Text section in the dashboard is blank as well..
So, are you sure these are all the steps I need to take to call javascript function in OBIEE?
Do I need to define anything in weblogic or other places?
I hope I am not missing any steps..
Thanks and let me know.. -
About the filter function in OBIEE 11g
Hi, all.
when i use the filter function in OBIEE 11g, it turn out a wrong result.
The operation steps and detail are described as follow:
1. In the Column Formula pane, I typed the Formula of the column 'count of customer' as:
FILTER(count(distinct("customer info dimesion"."customerID")) USING ("TradeType Dimesion"."TradeType" = '001'))
2. But the phisical SQL about this column in the NQquery file is that: "count(distinct(T11520.CUSTOMERID)) as c5, "
which means that, the filter wasn't applied, right?
If so, what shall I do in this situation, in other words , how can i make a Condition COUNT?
Any Suggestion is appreciated!
Thank you in advance~~O(∩_∩)O~Hi katherine,
FILTER(count(distinct("customer info dimesion"."customerID")) USING ("TradeType Dimesion"."TradeType" = '001'))I think your formula there is mistake like many braces...instead type this in your f(x)
=>Filter(count(distinct customer_id) USING trade type='001')
This filter function is same like a case statement,if you filter still gives error write a case statement
CASE WHEN TradeType Dimesion.TradeType='001' THEN count(distinct customer info dimesion.customerID) ELSE 0 END
Will it be helpful?,follow this etiquette http://forums.oracle.com/forums/ann.jspa?annID=939
By,
KK -
Subtotal issue when subtotaling on a calc field built using CASE function
Okay, I hpe I can explain this well. May be possible that this is something cannot handle in Discoverer. I am using Discoverer Plus to develop a new workbook - cross project expenditure inquiry. A requirement is to not allow a worksheet user to see labor cost (since possible to figure out someone's salary) amount unless they are allowed to view labor cost. I have a function that returns a Y/N value that tells me if they can view labor cost. That works out just fine. So what I am doing is taking my database cost column (which is defined as Number(22,5) in the Oracle table. I create a new calculated column, basically like this -
CASE WHEN expenditure type <> LABOR THEN cost WHEN view labor cost = 'Y' THEN cost ELSE NULL END.
That calculated column is working just fine. I am seeing my desired results in that column. Okay so far.
Next, the users want subtotals by project organization and project. So I created a new total. When I did that, my subtotal row amount is blank.
Okay, I have seen this happen with NULLS before. Like in the gl_je_lines tables, where the accounted_Dr and accounted_Cr may be null, and have to do a NVL function to convert the null to 0 and allow me to subtotal on the column in a Discoverer workbook.
So I tried creating a second calculation -
NVL(Cost,0)
So I return the cost if not null, otherwise I return 0. Second calc column results look okay.
Now I did a subtotal on the second calculation. Oops. Wrong result. Amount is shown as 0.
For grins, I went back to my CASE statement on my first calculation and changed the ELSE condtion from NULL to 0. When I did that, the subtotal on that column changes from a blank (Null) value to a 0 value. Well, better, but still just like my second calculation subtotal.
Obviously the users have the option to export to Excel and subtotal in Excel.
Does anyone know of a way to get a good subtotal in this kind of situation, where I am attempting to subtotal on a calculated field that is built on a CASE function? Or am I out of luck when it comes to Discoverer?
John DickeyOkay, I did find a workaround, though I do not understand why the workaround works, but why the way I first tried to get a subtotal did not work. What I did is that I had to go to Discoverer Administrator. I picked my folder and did an Insert/Item. I created my new item building the same CASE statement that I used in my worksheet to create a new calculation. I then closed Discoverer Plus and reopened Discoverer Plus. Opened my worksheet. Edited the worksheet and brought in my new (derived) item from my folder. Then I created my subtotals for this secured cost amount. Voila. I get a number now, and the subtotal amount appears to be correct (still testing/verifying, but looks okay so far). So I deleted my subtotals on my calculated column and then deleted the calculation, to get that stuff out of the report. Sure would be nice if there was documentation in the Discoverer manuals about this.
John Dickey -
How to use Table valued MSSQL function in OBIEE
Hi all,
Can some one help me to understand how to use table valued function in OBIEE? I want to use a table valued function (MSSQL function, with some input parameter), in the physical layer to pull the data?
I know for MSSQL Stored Procedure we can write as
EXEC SP_NAME @Parameter = 'VLUEOF(NQ_SESSION.Variablename)'
but now I have a table valued function in the query window I can get the data as
select * from myfunction(parametervalue)
In physical layer of OBIEE I have tried as
select * from myfunction('VLUEOF(NQ_SESSION.Variablename)'), but I'm getting error as the NQ_SESSION variable doesn't have a value , but actually I have initialized the variable but still Im getting error.
Can some one help me to solve this.
Thanks,
MithunFollow this link and try yourself. let me know for issues
Substring instr issue in obiee
Appreciate if you mark
Edited by: Srini VEERAVALLI on Feb 20, 2013 8:13 AM -
How to use, Case function and Filter in Column Formula?
Hello All,
I am using case function and also would like to filter value to populate.
Below is showing error :
case
when '@{Time}' = 'Year' then "Time"."Fiscal Year"
when '@{Time}' = 'Quarter' then "Time"."Fiscal Quarter"
when '@{Time}' = 'Month' then FILTER ("Time"."Fiscal Period" USING "Time"."Fiscal Period" NOT LIKE 'A%')
else ifnull('@{Time}','Selection Failed') end
Thanks, AKwhen '@{Time}' = 'Month' then FILTER ("Time"."Fiscal Period" USING "Time"."Fiscal Period" NOT LIKE 'A%')I dont think Filter this works here or any other data types except number.
Try to use option Column's->Filter->Advanced->Convert this filter to SQL
If helps mark -
What is the difference betwee decode & case function
Hi
What is the difference betwee decode & case function
1.decode can't used in pl/sql 1) case can be user
2.in decode we can't use (>,<,>=) 2) we can use
any other do u have....
thanks in advance....DECODE works with expressions which are scalar values.
CASE can work with predicates and subqueries in searchable form.
There is one more Important difference between CASE and DECODE
DECODE can be used Only inside SQL statement....
But CASE can be used any where even as a parameter of a function/procedure
Eg:-
SQL> create or replace procedure pro_01(n number) is
2 begin
3 dbms_output.put_line(' The number = '||n);
4 End;
5 /
Procedure created.
SQL> set serverout on
SQL> var a varchar2(5);
SQL> Begin
2 :a := 'ONE';
3 End;
4 /
PL/SQL procedure successfully completed.
SQL> Begin
2 pro_01(Decode(:a,'ONE',1,0));
3 End;
4 /
pro_01(Decode(:a,'ONE',1,0));
ERROR at line 2:
ORA-06550: line 2, column 9:
PLS-00204: function or pseudo-column 'DECODE' may be used inside a SQL
statement only
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored
SQL> Begin
2 pro_01(case :a when 'ONE' then 1 else 0 end);
3 End;
4 /
The number = 1
PL/SQL procedure successfully completed.Message was edited by:
Avi
Message was edited by:
Avi -
Hi All,
I tried using Evaluate and Evaluate_Aggr in the column formula of a report.
Evaluate_Aggr() is erroring saying the dimension Work Order is incorrectlly defines logical Table Source Mapping for a dimension of Work Order. If I revoke the implicit fact coniguration on this Subject Area which I have, the report executes as expected. But this implicit configuration is required in my scenario for other reports to work.
Using Evaluate() works perfectly.
Can anyone help me in fixing this?
Shld I add any other configuration in the RPD to resolve this issue?
Thanks996933 wrote:
hi all
i got this error when i try to execute evaluate function in obiee answer
nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <(>: Syntax error [nQSError: 26012] . (HY000)
SQL Issued: SELECT DGN_TIME_RES_USAGE_CUBE.DRTCLN_WO_NO, DGN_TIME_RES_USAGE_CUBE.HOURS, DGN_TIME_RES_USAGE_CUBE.PROJ_NO, EVALUATE('FUNC_FIND_EMPLOYEE_DESC(%1,%2,%3)','KASA',DGN_TIME_RES_USAGE_CUBE.DRTCHD_EMP_ID,1), RMAX(DGN_TIME_RES_USAGE_CUBE.DRTCHD_DATE), RMIN(DGN_TIME_RES_USAGE_CUBE.DRTCHD_DATE) FROM LIVE2 years back post from the next time open new thread ? (Business Intelligence Suite Enterprise Edition )
Thanks,
Saichand -
Use EVALUATE function in obiee
Hi ALL
i hv a database query like this;
select
deptno,
rtrim (xmlagg (xmlelement (e, ename || ',')).extract ('//text()'), ',') enamesfrom
emp
group by
deptno;
now, i want to use this using Evaluate function in obiee column formula.
thn how to do it.
Please reply.
THX
SAPHello SAP,
I have seen you for sometime and one thing I came to know is you are creating threads and once you got your solution or you dont feel to follow up you are just leaving the thread.
see few here,
Sorting month name
Drill down problem
Re: Filter in Union Request
so please better close the threads which are answered and proceed further. -
Dense Lookup Function in OBIEE
Hi ,
Can someone please explain the syntax of Dense Lookup Function in OBIEE.
The function in the built-in RPD is using too many arguments and I am not able to understand it.
Thanks in Advance for the help.
AkshathaI had actually seen all those links. Thanks for your time although.
Actually, I have an expression like this.
lookup( DENSE LookupTable.DOMAIN_MEMBER_NAME, 'MCAT', 'CMP' || '~' || Table_A.TOP_LVL_PRODCAT_ID, VALUEOF(NQ_SESSION.USER_LANGUAGE_CODE), Table_A.DATASOURCE_NUM_ID)
I am not sure of what 'MCAT' and 'CMP' is here?
Is the || the concatenation operator?
Can you please explain this expression?
I hope I am not asking too much here :/
Akshatha -
How to use CHOOSE function in OBIEE
Hi,
Could any one help me out in using the choose function in OBIEE.
How can a column be restricted using the choose function, when different users belonging to different groups logs in.
RakeshIt seems be obvious that you should not publish reports to users and groups who are not allowed to see the columns in the report,
but in practice it can be very challenging to oversee this, especially when you have a lot of groups and a very strict security model....or "unsurmountable" and unchangeable "business requirements" ;-)
Testing definitely is the crucial point. And when you start going nuts with column access rights plus column selectors, dynamic view switching, guided nav., dynamic column formulae etc. etc. the fun really begins. -
Unable to use WriteBack function in OBIEE on a Unix setup
Hi All
I am trying to implement the writeBack function in OBIEE. We have OBIEE installed on a Unix machine. Below is the xml that I have writte, it keeps erroring stating that the xml file cannot be read.
<?xml version="1.0" encoding="utf-8" ?>
<WebMessageTables xmlns:sawnm="com.siebel.analytics.web/message/v1">
<WebMessageTable lang="en-us" system="WriteBack" table="Messages">
<WebMessage name="forecast">
<XML>
<writeBack connectionPool="MOM_BI">
<Insert></Insert>
<Update>UPDATE STORE SET STORE_NAME='{@c1}' WHERE STORE={@c0}</Update>
<postUpdate>COMMIT</postUpdate>
</writeBack>
</XML>
</WebMessage>
</WebMessageTable>
</WebMessageTables>
Below is the log that I've received from OBIEE:
Error loading XML Message File (/app/oracle/product/OBIEE10133/OracleBI/web/msgdb/CustomMessages/forecast.xml): Sax parser returned an exception.
Message: Invalid document structure, Entity publicId: /app/oracle/product/OBIEE10133/OracleBI/web/msgdb/CustomMessages/forecast.xml, Entity systemId: , Line number: 2, Column number: 1^M
Error Codes: UH6MBRBC^M
Could you please let me know what is wrong with my xml file? By the way I only want to do an update to my table. Also I have followed all the examples from Venkat and others but I stil cannot get it to work.
Regards
AdnanIt's already good to know that the file gets picked up.
What I don't understand: "The log files are not being updated with the error however when I re-save my Answer it is populating the log file to state that the object already existed."?
I had to put a fake "insert" statement to get it working once. Here's the example:
<?xml version="1.0" encoding="utf-8"?>
<WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1">
<WebMessageTable lang="en-us" system="WriteBack" table="Messages">
<WebMessage name="ELT_Upside">
<XML>
<writeBack connectionPool="ELT_Writeback_Pool">
<update> UPDATE T_DW_LOGIC_ELT_UPSIDE SET COMMENTS='@{c0}', AMOUNT=@{c1}, LAST_UPDATED_BY='@{c6}', LAST_UPDATE_DATE=TO_TIMESTAMP('@{c7}', 'YYYY-MM-DD HH24:MI:SS.FF3') where UPSIDE_COMMENT_ID=@{c2} </update>
<insert> UPDATE T_DW_LOGIC_ELT_UPSIDE SET COMMENTS='@{c0}', AMOUNT=@{c1}, LAST_UPDATED_BY='@{c6}', LAST_UPDATE_DATE=TO_TIMESTAMP('@{c7}', 'YYYY-MM-DD HH24:MI:SS.FF3') where UPSIDE_COMMENT_ID=@{c2} </insert>
</writeBack>
</XML>
</WebMessage>
<WebMessage name="ELT_Downside">
<XML>
<writeBack connectionPool="ELT_Writeback_Pool">
<update> UPDATE T_DW_LOGIC_ELT_DOWNSIDE SET COMMENTS='@{c0}', AMOUNT=@{c1}, LAST_UPDATED_BY='@{c6}', LAST_UPDATE_DATE=TO_TIMESTAMP('@{c7}', 'YYYY-MM-DD HH24:MI:SS.FF3') where DOWNSIDE_COMMENT_ID=@{c2} </update>
<insert> UPDATE T_DW_LOGIC_ELT_DOWNSIDE SET COMMENTS='@{c0}', AMOUNT=@{c1}, LAST_UPDATED_BY='@{c6}', LAST_UPDATE_DATE=TO_TIMESTAMP('@{c7}', 'YYYY-MM-DD HH24:MI:SS.FF3') where DOWNSIDE_COMMENT_ID=@{c2} </insert>
</writeBack>
</XML>
</WebMessage>
<WebMessage name="ELT_Outlook">
<XML>
<writeBack connectionPool="ELT_Writeback_Pool">
<update> UPDATE T_DW_LOGIC_ELT_OUTLOOK SET AMOUNT=@{c4}, LAST_UPDATED_BY='@{c6}', LAST_UPDATE_DATE=TO_TIMESTAMP('@{c7}', 'YYYY-MM-DD HH24:MI:SS.FF3') where OUTLOOK_COMMENT_ID=@{c0} </update>
<insert> UPDATE T_DW_LOGIC_ELT_OUTLOOK SET AMOUNT=@{c4}, LAST_UPDATED_BY='@{c6}', LAST_UPDATE_DATE=TO_TIMESTAMP('@{c7}', 'YYYY-MM-DD HH24:MI:SS.FF3') where OUTLOOK_COMMENT_ID=@{c0} </insert>
</writeBack>
</XML>
</WebMessage>
</WebMessageTable>
</WebMessageTables>
Cheers,
C. -
Percentile_Disc Function in OBIEE 10g - Help needed at the earliest
Hi All,
I have a requirement of using PERCENTILE_DISC function in OBIEE 10g repository. I tried NTile function, to fetch the percentile. But that is not what am intending to see.
I have a requirement something similar to this, to be implemented in repository. Could anyone throw some light in this regard?
PERCENTILE_DISC(.25) WITHIN GROUP (ORDER BY F.Days asc) OVER (PARTITION BY A.NAME, B.PLACE)
Here F = Fact
A = 1st Dimension
B = 2nd Dimension
Days = Is calculated as TIMESTAMPDIFF(SQL_TSI_DAY, A.DATE, B.DATE). Established Inner Join, to fetch this calculation in to the FACT
Appreciate your responses at the earliest. Thanks once again.
Regards,
Sarat NallapatiHi,
I don't have any idea on percentile_disc.
But,in OBIEE we have a function PERCENTILE()
It will give the percentage of each value in the total sum of all the values.
once check it.
Regards,
Lakshmipathi.
Maybe you are looking for
-
Customer presently has Webex Meeting place in cloud for all its users with IM and Presence capability and they are planning to implement a UC Solution Will it be required to convert Webex Client to Jabber since client needs only one interface on the
-
How to call program through process chain
Hi Gurus, I am in the position to execute the abap program through process chain, I have used abap program as process type in process chain(First time I am using this process type).when I am executing the process chain, the abap program is not execu
-
Just did the upgrade to ios6, lost utube I get its owned by google, but didn't expect that. I know I can u tube via safari, Problem is I can't use air play to stream videos via Apple TV to my big screen. Very upset. How can I revert back?
-
I'm on Snow Leopard (10.6.8) in a last-generation MacBook Pro and having trouble with the Shared list in Finder. A few months ago, it stopped showing the server on the network at work. I see corworker computers still and can connect via Cmd+K, but it
-
Transferring captions between iPad and MacBook Pro using iPhoto
I have a new iPad3 on which I loaded the iPhoto App. When travelling, I load my photos from my Nikon D90 to the iPad. I then go into edit and add a caption. Once home, I hook my iPad up to my MacBook Pro (2007)(running Lion)(iphoto '11 v9.2.3) and th