DAX - how to use dax to return a previous row value?
Hi,
I was trying to use the EARLIER function but couldn't make it work:
EVALUATE
SUMMARIZE (
CALCULATETABLE (
'Inscricoes',
'Ano Letivo'[ID_TB_DIM_ANO_LETIVO] <= VALUE(26),
'Ano Letivo'[ID_TB_DIM_ANO_LETIVO] > VALUE(26) - 5,
'Escola'[ID_TB_DIM_UNIDADE_ORGANICA] = VALUE(6),
Curso[ID_TB_DIM_CURSO] = VALUE(372),
'Tipo de Inscricao no Curso'[DS_TIPO_INSCRICAO_CURSO]
= "Matrícula"
'Ano Letivo'[ID_TB_DIM_ANO_LETIVO],
'Ano Letivo'[DS_ANO_LETIVO],
"NR_INSCRICOES", [NR_ESTUDANTES_INSCRITOS])
This generates:
ID_TB_DIM_ANO_LETIVO
DS_ANO_LETIVO
NR_INSCRICOES
22
2010-11
93
23
2011-12
101
24
2012-13
84
25
2013-14
85
26
2014-15
104
I need a new field that does returns the previous value of subscriptions (NR_INSCRICOES), so last 2 columns will be:
93 -
101 - 93
84 - 101
85 - 84
104 - 85
Need some help. Thanks
Hi Pedro,
According to your description, you want to get the previous row data along with each row. Right?
In DAX, we can use EARLIER() function to achieve this requirement. Please refer to link below:
PowerPivot DAX Session Notes 2 – Previous Row
In this scenario, I suggest you select the three columns into one table(let's say TABLE1). Then you can try the expression below:
=CALCULATE(MAX(TABLE1[NR_ESTUDANTES_INSCRITOS]), (FILTER(TABLE1,EARLIER(TABLE1[ID_TB_DIM_ANO_LETIVO])>TABLE1[ID_TB_DIM_ANO_LETIVO])))
Reference:
EARLIER Function (DAX)
Best Regards,
Simon Hou
TechNet Community Support
Similar Messages
-
How to use NODIM func with out it's values being rounded
I created a new calculated key figure in Query Designer 3.x, and used the function NODIM() - Value with out dimensions. When I use this function, the values are rounding off to the nearest value.
For example, I have a value 0.000075 US$, when I use NODIM function the value is displayed as 0.000080. Value is getting rounded to nearest value.
I tried using absolute value it did not work.
Can any one tell me how to use NODIM function with out it's value being rounded to nearest value.
Thanks,Hi,
According to your description, you might want that "Notice" field has a default value when form is created and users can be able to change the value of that
field.
As a workaround, you can add an action rule in “Name” field via InfoPath to fill the default value in “Notice” field only when “Name” field is not blank and “Notice”
field is blank.
Settings of the rule are as below, you can modify it based on your need:
Here is a link about how to add an action rule in InfoPath form, you can use it as a reference:
https://support.office.microsoft.com/en-us/article/Add-rules-for-performing-other-actions-5322d726-b787-4e5f-8d37-ba6db68b451d?CorrelationId=8a64c12f-aa60-4d90-b1f9-a44fcc4e74b5&ui=en-US&rs=en-US&ad=US
Best regards
Patrick Liang
TechNet Community Support -
How to propogate previous row value
All,
I have a query were I need to fill the null data with previous row value. Like I have a table were we record all the On hand quantity for a item for a date. Lets say I have only 2 rows in this table for a month then I am planning to write a view that will give me 31/30 rows for a month and if for a specific date is the value is null then it should read from previous row unitl it finds the data otherwise display 0.
Ex. Actual table
Item No Date Qty
1 1/1/2010 10
1 1/5/2010 15
View I have written, I need to fill the null Qty with previous row data
Item No Date Qty
1 1/1/2010 10
1 1/2/2010
1 1/3/2010
1 1/4/2010
1 1/5/2010 15
1 1/6/2010
I want something like this how can i do this?
Item No Date Qty
1 1/1/2010 10
1 1/2/2010 10
1 1/3/2010 10
1 1/4/2010 10
1 1/5/2010 15
1 1/6/2010 15
ThanksHi Sung, sorry by my delay
Basically I'm building a Client Framework that a lot of actions are automatically managed, then I extend Objects
for example EntityImpl. I let to user set any value to the
database mapped fields but I will check this values
using my own bussines rules before to insert into database
and if this values are wrong I display an alert.
My problem is that I catch insert event to call validate
functions. But when any value is wrong I will show an alert, but if user commits transaction after validate
funcion is not revalidated. Well I supose that is a bad implementation for validation rules, now amb reading about
Validationlistener because I think is the best way to do
all that I need. I let to the user add field values but
these values not will commited while validationListeners
return isValid = true;
Thanks Sung.
Albert. -
I have a master detail form based on two tables. In the DETAIL_BLOCK section I have an item named 'APPROVAL_STATUS' based on the column of the same name in the underlying table. I have an unassociated textbox named CURR_APPROVSTAT in the detail form for which I would like to set it's default value to the current value of APPROVAL_STATUS when the master detail form is opened in %3D mode via a hyperlink.
I have tried using the p_session.get_value_as_varchar2 in the default value field of the CURR_APPROVSTAT item, but it generates errors on run.
EX:
Item CURR_APPROVSTAT
default value field
p_session.get_value_as_varchar2(
p_block_name => 'DETAIL_BLOCK',
p_attribute_name => 'APPROVAL_STATUS')
Default Value type:
Function returns varchar2
on run, it generates error that p_session must be declared (I get the same error if I use portal.p_session... also).
default value field
select p_session.get_value_as_varchar2(p_block_name => 'DETAIL_BLOCK', p_attribute_name => 'APPROVAL_STATUS')from dual
Default Value type:
SQL returns varchar2
on run, it generates and error that a right parenthesis is missing.
I have also tried using the following in the Additional PL/SQL - before displaying form:
p_session.set_value
(p_block_name => 'DETAIL_BLOCK'
,p_attribute_name => 'CURR_APPROVSTAT'
,p_value => p_session.get_value_as_varchar2(
p_block_name => 'DETAIL_BLOCK',
p_attribute_name => 'APPROVAL_STATUS')
on run, this generates the error identifier 'P_SESSION.GET_VALUE_AS_VARCHAR2' must be declared
My questions are:
1) is it possible to use the p_session.get_value_as_varchar2 in the default value field?
2) If yes, then what if the proper syntax
3) If no, can I set this value when the MD form opens from the additional pl/sql triggers, and if so, what is the syntax?
any assistance you can offer is greatly appreciated.
Sincerely,
ARMIn my detail block I have 10 rows displaying that may or may not have data after querying. To set the default value in the detail block, you have to set the index value of p_session.set_value. Since I don't know how many rows are already populated, I'm setting the default value to all 10 rows. Is there a better approach?
Here's my code example, which I've placed in the additional PL/SQL section before displaying the form...
DECLARE
l_district_id VARCHAR2(7);
BEGIN
l_district_id := p_session.get_value_as_varchar2
(p_block_name => 'MASTER_BLOCK',
p_attribute_name => 'A_DISTRICT_ID');
FOR i in 1 .. 10 LOOP
p_session.set_value
(p_block_name => 'DETAIL_BLOCK',
p_attribute_name => 'A_DISTRICT_ID',
p_value => TO_CHAR(l_district_id), p_index => i);
END LOOP;
END; -
How to Bring the Quarter Period and Previous Month Value for given Input
Hi to all,
I want bring Quarter Period and Previous Month value for the given Input. Plz help me on this
Example :
Input : 06.2008
Output:
Input Prev.Month Quarter 1 Quarter 2 Quarter 3
06.2008 05.2008 03.2008 12.2007 09.2008
12.2008 11.2008 09.2008 06.2008 03.2008
Is there any Standad Exit for this or we have to write coding ?
Regards,
SaranHi,
You can solve this by using Replacement path.There you have a option offsets.Here give the current period.Based on that give the number which previouse month you suppose to want.
I think this 'll help you
assign points if this helps
Regards
JT Goud -
Compounding using previous row values
Greetings!
Im trying to write SQL in Oracle 10.2.0.4. I have no success using OVER , PARTITION analytic functions. Can someone help with this requirement..
Data :
with t as (select 1 AS Calc_Seq, 700 as erncd, 0.05 as pct, 22 Hrly from dual union all
select 2, 701, 0.05 , 22 from dual union all
select 3, 702, 0.075 , 22 from dual)
SELECT T.Calc_Seq,T.erncd,T.pct,T.hrly FROM T;
Output required as follows ...
Need compounded rate field, as PCT rate of previous row "Compounded rate" field value.
CALC_SEQ ERNCD PCT HRLY Compounded rate
1 700 0.05 22 23.1
2 701 0.05 22 24.255
3 702 0.075 22 26.074125Thanks in advance.
Edited by: Rama on Jan 9, 2013 11:39 AM
Edited by: Rama on Jan 9, 2013 11:50 AMHi,
Try this:
WITH
t AS
SELECT 1 AS Calc_Seq ,700 AS erncd ,0.05 AS pct ,22 Hrly FROM dual UNION ALL
SELECT 2 ,701 ,0.05 ,22 FROM dual UNION ALL
SELECT 3 ,702 ,0.075 ,22 FROM dual
SELECT
FROM
T
model
dimension by (calc_seq)
measures (erncd, pct, hrly, 0 cr)
rules
cr[any] order by calc_seq = case when cv(calc_seq) = 1 then hrly[cv(calc_seq) ] * (1 +pct[cv(calc_seq)])
else cr[ cv() -1] * (1 + pct[cv()]) end
CALC_SEQ ERNCD PCT HRLY CR
1 700 0.05 22 23.1
2 701 0.05 22 24.255
3 702 0.075 22 26.074125 Regards,
Peter -
at the top of page on left side there used to be a previous page arrows those arrows dont come up anymore i used them alot how do i get them back on there? this is what they look like < > help.
Hello Thediamond
Go to the iTunes preferences, go to the Store tab and check to see if the Show iTunes in the Cloud Purchases. Also check to see if any purchases are hidden as well.
Downloading past purchases from the iTunes Store, App Store, and iBooks Store
http://support.apple.com/kb/HT2519
iTunes Store: Hiding and unhiding purchases
http://support.apple.com/kb/HT4919
Thanks for using Apple Support Communities.
Regards,
-Norm G. -
How to use RefCursor to return millions of records
I have a stored Procedure which returns a RefCursor. Following is the query which is used to open the RefCursor. this query gets executed in 7 seconds and it returns 13,00,000 records. It takes hours to show them in the dotnet application.
SELECT
CO.COMPANY_ID AS COMPANY_ID,
PCH.HOLDING_ID AS HOLDING_ID,
CO.NAME AS FIRM_NAME,
PCC.NAME AS "Sub-Account Name",
PCC.PORTFOLIO_CLASS_NAME AS "Sub-Account Type",
H.COUPON_RATE AS COUPON_RATE,
NVL(TO_CHAR(H.COUPON_RATE),F_GETCODE(H.COUPON_STRUCTURE_ID,'CPN')) AS COUPON_FIELD,
TO_CHAR(H.MATURITY_DATE,'DD-MON-YYYY') AS MATURITY_DATE,
CO.ALPHA_NAME AS ALPHA_NAME,
H.ISSUER_NAME AS ISSUER_NAME,
H.ISSUER_ALPHA_NAME AS ISSUER_ALPHA_NAME,
PCH.FI_PAR_AMOUNT AS "Currency Par (000s)",
PCH.FI_NET_CHANGE AS "Net Change (000s)",
PCH.FI_BONDS_HELD AS "# of Bonds Held",
TO_CHAR(CO.REPORT_DATE,'DD-MON-YYYY') AS REPORT_DATE,
H.NAME AS ISSUEDESC,
H.ISSUER_COUNTRY_NAME AS ISSUER_COUNTRY_NAME,
F_GETCODE(H.ISSUER_STATE_ID,'S') AS ISSUER_STATE_NAME,
TO_CHAR(H.ISSUE_DATE,'DD-MON-YYYY') AS ISSUE_DATE,
H.LEAD_MANAGER AS LEAD_MANAGER,
H.CURRENCY_CODE AS CURRENCY_CODE,
PCH.MARKET_SECTOR_CODE AS MARKET_SECTOR_CODE,
H.CUSIP AS CUSIP,
H.ISIN AS ISIN,
H.ISSUER_TICKER_SYMBOL_TEXT AS "Primary Exchange Equity Ticker",
H.PLEDGE_NAME AS "Instrument/Pledge",
H.COLLATERAL_NAME AS "Collateral/Purpose",
H.ISSUER_CREDIT_SECTOR_NAME AS "Issuer Credit Sector",
H.COUPON_STRUCTURE_NAME AS "Coupon Structure",
H.SP_RATING_NAME AS "SP Rating",
H.MOODYS_RATING_NAME AS "Moodys Rating",
H.FITCH_RATING_NAME AS "Fitch Rating" ,
P.HONORIFIC_PREFIX_CODE AS HONORIFIC,
P.FIRST_NAME AS FIRST_NAME,
P.MIDDLE_INITIAL AS MIDDLE_INITIAL,
P.LAST_NAME AS LAST_NAME,
P.DISPLAY_FUNCTION_NAME AS Title,
P.DIRECT_DIAL_PHONE AS "DIRECT DIAL PHONE",
D.PHONE_CODE AS "Country Phone Code",
P.EMAIL_ID AS "Email Address",
CO.MAIL_ADDRESS_LINE1 AS MAIL_ADDRESS_LINE1,
CO.MAIL_ADDRESS_LINE2 AS MAIL_ADDRESS_LINE2,
CO.MAIL_CITY_NAME AS MAIL_CITY_NAME,
CO.MAIL_STATE_CODE AS MAIL_STATE_NAME,
CO.MAIL_ZIP_CODE as "Firm Postal Code",
CO.LOC_ADDRESS_LINE1 AS LOC_ADDRESS_LINE1,
CO.LOC_ADDRESS_LINE2 AS LOC_ADDRESS_LINE2,
CO.LOC_CITY_NAME AS LOC_CITY_NAME,
CO.LOC_STATE_CODE AS LOC_STATE_NAME,
CO.LOC_ZIP_CODE,
CO.LOC_COUNTRY_NAME AS LOC_COUNTRY_NAME,
C.PHONE_CODE AS "Firm Country Phone Code",
CO.PHONE_NUMBER AS PHONE,
CO.FAX_NUMBER AS FAXNO,
/* COUNT(PCH.COMPANY_ID) OVER (PARTITION BY PCH.COMPANY_ID ORDER BY PCH.COMPANY_ID) AS ROW_CNT,
COUNT(DISTINCT CO.COMPANY_ID) OVER() AS FIRMCOUNT,
COUNT(DISTINCT CO.COMPANY_ID) OVER() AS TOTAL_RECORDS,
COUNT(DISTINCT PCC.PORTFOLIO_COMPANY_CUSTOMER_ID) OVER(PARTITION BY CO.COMPANY_ID) AS FUNDCOUNT,
COUNT(DISTINCT PCC.PORTFOLIO_COMPANY_CUSTOMER_ID) OVER() AS FUNDPORTFOLIOCOUNT,
COUNT(DISTINCT H.HOLDING_ID) OVER(PARTITION BY CO.COMPANY_ID,PCC.PORTFOLIO_COMPANY_CUSTOMER_ID) AS ISSUECOUNT,
PCC.PRIVATE_PORTFOLIO_FLAG,
PCC.TOP_TEN_HOLDINGS_FLAG ,
TO_CHAR(SYSDATE,'DD/MM/YYYY HH:MM:SS') TI
FROM
PORTFOLIO_COMPANY_HOLDING PCH,
HOLDING H,
COMPANY CO,
PORTFOLIO_COMPANY_CUSTOMER PCC,
PERSON P ,
PERSON_PORTFOLIO PP,
COUNTRY C,
COUNTRY D
WHERE
PCH.HOLDING_ID=H.HOLDING_ID
AND PCH.COMPANY_ID=CO.COMPANY_ID
AND PCH.PORTFOLIO_COMPANY_CUSTOMER_ID=PCC.PORTFOLIO_COMPANY_CUSTOMER_ID
AND P.EMPLOYEE_ID = PP.EMPLOYEE_ID
AND CO.COMPANY_ID=PP.COMPANY_ID
AND CO.COMPANY_ID=PCC.COMPANY_ID
AND PCC.PORTFOLIO_COMPANY_CUSTOMER_ID = PP.PORTFOLIO_COMPANY_CUSTOMER_ID
AND C.COUNTRY_ID = CO.LOC_COUNTRY_ID
AND D.COUNTRY_ID= P.COMPANY_LOC_COUNTRY_ID
AND P.DISPLAY_COMPANY_CONTACT_FLAG = 'Y'
AND PCH.HOLDING_ID IN ( SELECT HOLDING.HOLDING_ID FROM MV_BOND HOLDING WHERE HOLDING.LANGUAGE_ID=2 AND INSTR(PATTNO_STRING,',96,')>0
-- AND (((HOLDING.MARKET_SECTOR_ID) IN (8209) )
AND (((HOLDING.CURRENCY_ID) IN (10000003) )
)i ran the query in TOAD it got executed in 7 seconds. but when i used the same query in stored procedure it was taking lot of time to complete pushing the data to the application. Need your help to tune the query.
-
How to use 'BAPI_GOODSMVT_CREATE' for more then one row selected ???
Hi,
I am using bapi , BAPI_GOODSMVT_CREATE , my requirement is that first perform ALV display with check boxes & then user can selsct any number of rows & then on clicking execute button this bapi is triggered , now my ques is that if i am selecting rows one by one & executing , then am able to post data successfully, but if am selecting more then one row at a time then its giving me error
" exactly one serial no must be selected (instead of more then two / three ) ."
plz help me .
this is how i am filling data in BAPi & bapi call
FORM FILL_BAPIDATA .
wa_GOODSMVT_HEADER-PSTNG_DATE = sy-datum.
wa_GOODSMVT_HEADER-doc_DATE = sy-datum.
wa_goodsmvt_code-gm_code = c_gmcode.
LOOP AT it_final INTO wa_final.
wa_GOODSMVT_ITEM-MOVE_TYPE = c_movtype. " '313'.
wa_GOODSMVT_ITEM-material = WA_final-MATNR.
wa_GOODSMVT_ITEM-ENTRY_QNT = wa_final-verme.
wa_GOODSMVT_ITEM-plant = WA_final-WERKS. "'DB10'.
wa_GOODSMVT_ITEM-STGE_LOC = WA_final-LGORT.
wa_GOODSMVT_ITEM-BATCH = WA_final-CHARG.
wa_GOODSMVT_ITEM-BATCH = l_charg.
append wa_GOODSMVT_ITEM to IT_GOODSMVT_ITEM.
clear: wa_GOODSMVT_ITEM.
ENDLOOP.
LOOP AT it_final INTO wa_final.
wa_serialnumber-SERIALNO = wa_final-sernr.
APPEND wa_serialnumber to it_serialnumber.
CLEAR wa_serialnumber.
ENDLOOP.
LOOP AT it_position2 INTO wa_position2.
wa_serialnumber-MATDOC_ITM = wa_position2-wepos .
MODIFY it_serialnumber INDEX sy-tabix from wa_serialnumber TRANSPORTING MATDOC_ITM .
ENDLOOP.,
data: begin of mthead.
include structure bapi2017_gm_head_ret.
data: end of mthead.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = wa_GOODSMVT_HEADER
GOODSMVT_CODE = wa_GOODSMVT_CODE
IMPORTING
GOODSMVT_HEADRET = mthead
MATERIALDOCUMENT = w_MATERIALDOCUMENT
MATDOCUMENTYEAR = w_MATDOCUMENTYEAR
TABLES
GOODSMVT_ITEM = IT_GOODSMVT_ITEM
GOODSMVT_SERIALNUMBER = IT_SERIALNUMBER
RETURN = IT_RETURN
GOODSMVT_SERV_PART_DATA =
EXTENSIONIN =
APPEND w_MATERIALDOCUMENT to it_GOODSMVT1 .
IF sy-subrc = 0 .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*MESSAGE text-016 TYPE 'I'.
PERFORM msg_log .
ENDIF.Hi,
Did u check the serial numbers table before calling the BAPI. Might be the case tht same serial number is assigned for all items, in this case the goods movement may be possible with same serial number for all items.
Reagrds,
Aditya
Edited by: aditya on Aug 11, 2009 11:46 AM -
How to use SQL import to set the attribute value based on another?
Hello all,
I want to set an attribute of a dimension based on another attribute (if matches). Let's say I have a dimension PRODUCT. And I have defined two user defined attributes MANAGER and ISVISIBLE.
Now within a PERMIT_READ program I want to set the ISIVISIBLE to true where the MANAGER Value is selected from a table.
Something like
<define a cursor c1 to select all the Manager values>
sql import c1 into -
:MATCHSKIPERR PRODUCT_MANAGER then <PRODUCT_ISVISIBLE (PRODUCT MANAGER) = true>
<etc>
Obviously the above is not correct. But I am stuck as to how this can be done? Can some one on this forum please help me with correct syntax/ approach please?
Thanks a lot.
Pxsheth
This statement assigns true to the isvisible attribute for every gc_dim_bu dimension (selected as part of cursor c1).
SO FAR SO GOOD.. NOW -
If I want to change the above so that the attribute value gets assigned based on another attribute for the dimension (say a flag). i.e.
Set the isvisible to true where attribute flag has a certain value. How do I code this in OLAP DML?There are a number of ways to do this. If you want to use an attribute that has been defined within AWM as an attribute of Product then simply using the mapping tool to populate the attribute as part of the normal dimension load procedure.
Alternatively you could create an attribute at the DML level, and assuming you are not using surrogate keys, you can then define a cursor to read the relational table to populate your attribute. Something like this:
sql declare MKT_BASKET cursor for -
select PRODUCT_ID, PROD_MGR , PROD_VISIBLE -
from PRODUCT_DIM
if SQLCODE ne 0
then goto ERROR
sql open MY_CURSOR
sql fetch MY-CURSOR loop into :append PRODUCT, :PRODUCT_MANAGER, :PRODUCT_ISVISIBLE
sql close MY_CURSOR
sql cleanup
update
commit
If you want to create a complex PERMIT function using OLAP DML then personally I would create a formula and assign a program of type BOOLEAN and have the program return a YES or NO depending on the outcome of your test. Then your PERMIT_READ still references a dimension object. For example:
DEFINE PROD.ISVISIBLE BOOLEAN FORMULA <PRODUCT>
EQ PRG.ISVISIBLE(PRODUCT)
DEFINE PRG.ISVISBLE PROGRAM BOOLEAN
The program will then return Yes or No depending on the processing you need to do.
Hope this helps
Keith Laker
Data Warehouse Solution Architect
Oracle EMEA Consulting
BI Blog: http://oraclebi.blogspot.com/
DM Blog: http://oracledmt.blogspot.com/
BI on Oracle: http://www.oracle.com/bi/
BI on OTN: http://www.oracle.com/technology/products/bi/
BI Samples: http://www.oracle.com/technology/products/bi/samples/ -
Left outer join using date range returns too many rows
I am trying to pull data for a website.
Names table:
company_name varchar2(30)
julian_day varchar2(3)
logins number(3)
login_errors number(3)
Given a julian date range (e.g. 250-252), I am displaying the information from the Names table.
The problem is that I also need to display changes (increases/decreases) in the data. I do that by coloring the text based on a 10% increase/decrease. Data for the 3 days 250-252 would be compared to data for the previous 3 days 247-249.
Not all companies will report data on all days, so some gaps in the data may exist. Therefore, I cannot do just a simple join.
I am trying to write a query that will give me this information if the user chooses days 250-252.
Company_name
sum(logins) for days 250-252
sum(login_errors) for days 250-252
sum(logins) for days 247-249
sum(login_errors) for days 247-249
The query I'm using is:
select cur.company_name, sum(cur.logins),
sum(cur.login_errors), sum(old.logins), sum(old.login_errors)
FROM names cur LEFT OUTER JOIN names old
ON cur.company_name = old.company_name
WHERE cur.adate>='250' and cur.adate<='252'
and old.adate>='247' and old.adate<='249'
GROUP by cur.company_name
Given this data:
Company_name adate logins login_errors
ABC 247 10 10
ABC 248 20 20
ABC 249 30 30
ABC 250 15 15
ABC 251 25 25
ABC 252 35 35
My problem is that it returns:
adate cur.logins cur.login_err old.logins old.login_err
250 15 15 60 60
251 25 25 60 60
252 35 35 60 60
How can I get it to only give me the one "old" day's data? I went with the LEFT OUTER JOIN because it's possible that there is no data for an "old" day.
Thanks in advance.....Your problem stems from the join itself, and would be the same even without the OUTER JOIN. With your data, there are 3 records in cur and 3 records in old. The join matches each record in cur to each record in old resulting in 9 records in total. Without the SUM, this is clear:
SQL> SELECT cur.company_name, cur.logins, cur.login_errors,
2 old.logins, old.login_errors, cur.adate cad, old.adate oad
3 FROM names cur LEFT OUTER JOIN names old
4 ON cur.company_name = old.company_name
5 WHERE cur.adate>=250 and cur.adate<=252 and
6 old.adate>=247 and old.adate<=249;
COMPANY_NA LOGINS LOGIN_ERRORS LOGINS LOGIN_ERRORS CAD OAD
ABC 35 35 10 10 252 247
ABC 25 25 10 10 251 247
ABC 15 15 10 10 250 247
ABC 35 35 20 20 252 248
ABC 25 25 20 20 251 248
ABC 15 15 20 20 250 248
ABC 35 35 30 30 252 249
ABC 25 25 30 30 251 249
ABC 15 15 30 30 250 249
9 rows selected.You can do this with only one reference to the table.
SELECT company_name,
SUM(CASE WHEN adate BETWEEN 250 and 252 THEN logins ELSE 0 END) curlog,
SUM(CASE WHEN adate BETWEEN 250 and 252 THEN login_errors ELSE 0 END) curerr,
SUM(CASE WHEN adate BETWEEN 247 and 249 THEN logins ELSE 0 END) oldlog,
SUM(CASE WHEN adate BETWEEN 247 and 249 THEN login_errors ELSE 0 END) olderr
FROM names
WHERE adate BETWEEN 247 and 252
GROUP BY company_nameHTH
John -
How to use one dataTable to dynamically assign different values?
For example, there is only one popup window that contains one dataTable. For every commandButton that calls this popup window will result in different dataTables.
How to do that?
Thank you.I wanna reuse the same popup window page to display different dataTables with values based on which button(on father window) is clicked...
I use an html to include the popup window like this:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<frameset>
<frame src="popupMediaType.jsf" />
</frameset>
</html>
So there will be two pages for one popup window...and I call this html by javascript in the father window...
I wanna use just two pages to do all the work for other similar popup windows... -
How to get firefox to return to previous link and not reload it
When viewing content from a page in a tab, clicking the back button causes the previous page to reload in stead of just returning to it. That makes it impossible (without opening the info in a new tab) to return to a page and click the next item you want to view because it is no longer there.
Also, sometimes you get the message that the previous page is not available with a "try again" button.
I just want the back button to return to the previous page and NOT reload it.
I'm hoping there's an about:config setting that fixes this.
Version 32.0.3
TIAIn order to change your Firefox Configuration please do the following steps :
# In the [[Location bar autocomplete|Location bar]], type '''about:config''' and press '''Enter'''. The about:config "''This might void your warranty!''" warning page may appear.
# Click '''I'll be careful, I promise!''' to continue to the about:config page.
browser.cache.check_doc_frequency
Set how often to check accuracy of cached documents
* 0 : Once per session
* 1 : Each time
* 2 : Never
* 3 : When appropriate/automatically -
How to use String Function Find() in a String Value Test?
Hi,
i intend to match a substring of the string returned from my UUT when using a String Value Test - VI call.
I write the returned string to a Local Variable type String (Locals.data_read) and in the Limits Tab - under Expected String Value am using Find(Locals.data_read, "Connected"). When i Check the expression for Errors - i get a warning "Expected String, found Number {64-bit Floating Point}. this value will cause a run-time error."
What am i missing?
Thanks
Kech
Solved!
Go to Solution.The Find function evaluates to a number:
Number Find(String string, String stringToSearchFor, Number indexToSearchFrom = 0, Boolean ignoreCase = False, Boolean searchInReverse = False)
Returns: The zero-based character index, starting at the beginning of the string, of the first character in the substring. The function returns -1 if it does not find the substring.
It looks to me like you need to do a numeric step type. Not a string value test.
Or you can do something like this:
Find(Locals.data_read, "Connected") < 0 ? "Doesn't Matter What Is Here" : Locals.data_read
Hope this helps,
jigg
CTA, CLA
teststandhelp.com
~Will work for kudos and/or BBQ~ -
How to use PPR in Adv Tbl specific row specific UI element/attr/field
I have an editable advanced table, it has a controlling column that depending on the value you select will require or not require specific fields
how do I use ppr to enable this feature without risking affecting the other rows within the advanced table?
Example
Sample Table
Row 1, Value is "A" = Field 2 and Field3 is required
Row 2, Value is "B" = Filed 2 is required Field 3 is notFound a solution.
Create a transient attribute in the Adv Table target VO that will store "require" flags, e.g. RequireField1
Modify target field Required Attribute in the Advanced table UI, spel must point to this value.
catch and pass EVENT_SOURCE_ROW_ID_PARAM in the PPR event to the AM method.
set the RequiredField transient attr,
Maybe you are looking for
-
I had to restore my iphone 4 and now it wont let me activate the iphone with my apple id
I had to restore my iphone 4 via itunes and now it wont let me activate it with my own apple id and password. I have even tried changing the password. I know the phone is not stolen as i bought it new from an authorised dealer here in australia. It k
-
How do i change the cell color of each cell in datagrid dynamically
I have a datagrid filled in with data..My job is to change the cell color of a particular cell in the datagrid when the user clicks that cell..Please help me asap..I have to change the color of each cell dynamically..
-
Download to application server File tcode relavance
Hi i need to know the process for application server download and defining the same in file transaction also the process further to move the logical path to the TQA etc system also pls send me working example of the downloading to application server
-
I pod says it needs to be restored
ok my i pod screen say to restore my i pod using i tunes (in like 4 dif languages) So i did but then after its done it say "ITunes has detected an i pod in recovery mode. You must restore this i pod before it can be used with i tunes." So i did it an
-
Mail showing more messages being received than are received
I have been having something odd happen lately. When I open Mail, it shows incoming messages, just a bit ago it was 12, but nothing appeared in my inbox. Occasionally I catch subjects in the status bar, but it is too quick to see. I also have an iPho