Max of one column in another column
HI all
I have a scenario in the WebI report where I need to get the Maximum value from one column and use that maximum value in calculation of another column for each row in that column.
for ex:
column A
1
2
3
4
5
Max of column A [MAX]= 5
Column B
1/ [MAX]
2/[MAX]
3/[MAX]
4/[MAX]
5/[MAX]
Column B calculation is some thing like described above.
but my issue is, in WebI values are caluclated row wise and while generating values for the first row in column B, it picks the value 1 but the MAX value is not yet caluclated and if I use Max variable it is caluculating as 1/1 for first row and 2/2 and 3/3. Instead of 1/5, 2/5, 3/5.
Any idea please share it.
Thanks
Edited by: saathiyaa on Feb 19, 2011 1:23 AM
No its not working, well actually columb B is nothing but individual value of that row divided by max of that row
for ex:
1/5
2/5
3/5
4/5
5/5
But if i have formula like COLA/MAX[A]
it is cosidering as 1/1, 2/2, 3/3, 4/4.5/5
becuase webi caluclates row wise, so when it is in first row you will see maximum of that column is not yet calculated so it is taking as 1/1 not 1/5.
Similar Messages
-
How to place one column under another column in obiee report?
Hi all,
I am new to obiee, so need some help from obiee experts. Can anyone tell me how to place one column data under another column in obiee report?
i need the report to be as below
category total_students Course_enrollment Test_attended pass_test
total N % N % N %
all students ##### ## ## ## ## ## ##
Ethnicity
Asian ###### ## ## ## ## ## ##
African American ###### ## ## ## ## ## ##
white ######
Filipino ######
Gender
Male ##### ## ## ## ## ## ##
Female ##### ## ## ## ## ## ##
and similarly for other columns
where ethnicity, gender are columns in the table and Course_enrollment, Test_attended, pass_test are calculated columns.
Please help me to create a report as above if anyone knows how to do it.
Edited by: Shailaja on Jul 19, 2010 12:23 AMTwo ideas I can think of:
1) Create multiple pivot tables and then display them one under the other
2) Create multiple measure columns such as "male_amt", "female_amt", "white_amt", "asian_amt", "black_amt", etc. for all the columns you need. Then you could simple stack them in a single pivot table.
Option #2 might give you the prettiest results - but also requires a lot more maintenance (for instance, if you reclassify ethnic groups, you'd have to go through the reports to add additional metric columns).
Hope this helps,
Scott -
SQL update one column from another column
I'm looking for a way to update a SQL column with a portion
of info from another column in the same table.
example of a sql command
UPDATE table1
SET table1.columnname1 = table1.columnname2
FROM table
WHERE blah blah blah
Here's the thing... I only need a portion of the data found
in the source column. I'm not sure how I would do this then.
for example, the database has countries and states combined
into one column like this 'US-DC', 'US-CA', US-FL', etc. I want to
separate these into two columns, a country column and a state
column.... and I dont want to go though all the results and do this
line by line. How would I write the SQL command so that it puts
just the country in the country column, and puts just the state in
the state column, and it omits the dash all together.
any ideas?It depends. Are you using PHP and mySQL or ASP and SQL?
If you are using mysql and PHP you could use the following
code to loop through all records in your datatbase.
$sql="SELECT * FROM tablename"; //SET tablename to the name
of your database table.
$result=mysql_query($sql)or die(mysql_error(). " - $sql");
for($x = 0; $row=mysql_fetch_assoc($result); $x++){
//set up the variables from the table
$ID=$row['ID']; //this is the primary key
$var1=$row['contrystatecolumn']; //this is the name of the
column which holds the country-state
$var2=explode("-", $var1); //now we explode the string to get
the country and the state seperated and place the results into an
array
$country=$var2[0]; //this is the first piece of the exploded
string in the array
$state=$var2[1]; //this is the second piece of the exploded
string in the array
//now we update the database record with the new information
//remember to replace the tablename with your actual table
name and the columns country and state with the acutal names of
your columns in your table
$sql2="UPDATE tablename SET country='$country'.
state='$state' WHERE ID='$ID'";
$result2=mysql_query($sql2)or die(mysql_error() . " -
$sql2");
This code will loop through every record in your table and do
what you want very quickly.
Hope this helps
Stan Forrest
Senior Web Developer
ATG Internet -
Copy the data from one column to another column using @
I have two columns here - A and B.
Column A has a complicated formula that will generate results. I wanted the results in Column A to be reflected in Column B without pasting the A's formula in B. This will save me the trouble of editing formulas in more than 1 column if there is a need.
I saw somewhere that you can use "@" in column B but I have no idea how to use it.
Assumingly column A is the first column. I tried to insert '@1' in B's formula and change B's column properties' Data Format as "Treat Text as HTML". It does not work.
Please advise how I can do that.So is there any way to copy the data in Column A into Column B without putting the same formula? something like in Excel where we put "=C1". Its not possible in BI as it comes in excel.....The only way is to create a duplicate column in RPD or Answers screen and incorporate the formula and giving different name to it.
whats the problem if you duplicate the column with same formula?....Ok still if you dont want to see identical just write some pseudo logic say
Duplicated column f(x) case when 1=0 then column_name else formula end.....so it appears different to see but it outputs same.
UPDATED POST
Dont create in RPD,you can create a dummy column in that report request and change the f(x) to the above case i mentioned by taking the column from columns button in edit formula screen so when ever you edit the actual column formula that would reflect in the dummy column also as it is replicating from original one.Try and see
hope helps you.
Cheers,
KK
Edited by: Kranthi.K on Jun 2, 2011 1:26 AM -
Need Help in Next value of column to another column
Hi,
I am creating view in oracle 10g in which i have 1 custom column who's value are the next value of the another column.
E.g.
C 1 -----C2 ------ custom-C3
10 -------1 --------------2
10 ------ 2 ------------- 3
10 -------3 ------------- 3
11 -------1 ------------- 2
Now is there any function in oracle which gives me to generate "custom-c3"
which gives the data for next value of column 2
Thanks.Hi Frank,
Thank you so much......its working fine in 10 g.....
but for the last row of its coming emply or null but i want value of c2 if its last value.
e.g
C 1 -----C2 ------ custom-C3
10 -------1 --------------2
10 ------ 2 ------------- 3
10 -------3 ------------- 3
11 -------1 ------------- 2
In the above the value of c1 is 10 i.e last one then value of c3 should be value of c2 i.e. 3.
Can you use IF function?
Thanks.
Message was edited by:
user650690 -
Compare column to another column with a specific value?
What i need to do is compare a column that holds the SiteNames of holidays to another column with the DifficultyDescription of holidays.
I want to show that sites that are not included in boldANY*bold* holiday with an “easy” or “moderate” rating.
Some of my SiteNames have holidays with different difficulty ratings....
e.g Yellowstone National Park(SiteName) - H2 - Moderate(DifficultyDescrip)
Yellowstone National Park(SiteName - H3 - Strenuous(DifficultyDescrip)
In this example i would want Yellowstone not to be in the results of my query as one of its results is 'moderate'.
I want to show holidays that are not in boldANY*bold* holiday with 'easy' or 'moderate'
Here is my attempt so far...
select it220_holdet.holcode.holcode as holcode
it220_holdet.diffdetails.diffdescrip as diffdescrip
it220_sitedetails.sitename as sitename
from it220_holidaydetails it220_holidaydetails,
etc....
where it220_sitedetails.sitename != it220_diffdetails.diffdescrip = 'Easy' <<<< where the sitename is not equal to a difficulty description of 'Easy'
and it220_sitedetails.sitename != it220_diffdetails.diffdescrip = 'Moderate' <<<< where the sitename is not equal to a difficulty description of 'Moderate'
Is the logic of this correct? The error message i am getting is SQL command not properly ended.
Is this more of a syntax problem than logic. Any help would be great.
Thanks in advance!
Edited by: Jay on 19-Nov-2010 02:47
Edited by: Jay on 19-Nov-2010 02:47Hi,
Ok,
Problem is in this part of query
where "IT220_HOLIDAYDETAILS"."DIFFRATING"="IT220_DIFFDETAILS"."DIFFCODE"
and "IT220_HOLIDAYDETAILS"."HOLCODE"="IT220_LOOKUP_SITEHOLIDAY"."HOLCODE"
and "IT220_LOOKUP_SITEHOLIDAY"."SITECODE"="IT220_SITEDETAILS"."SITECODE"
and "IT220_SITEDETAILS"."SITENAME" = "IT220_DIFFDETAILS"."DIFFDESCRIP"
and "IT220_SITEDETAILS"."SITENAME" = "IT220_DIFFDETAILS"."DIFFDESCRIP"
Check are you joining correct columns.
And remove possibility that tables values are in different cases
SELECT "IT220_HOLIDAYDETAILS"."HOLCODE" AS "HOLCODE",
"IT220_HOLIDAYDETAILS"."COUNTRYVIS" AS "COUNTRYVIS",
"IT220_DIFFDETAILS"."DIFFDESCRIP" AS "DIFFDESCRIP",
"IT220_SITEDETAILS"."SITENAME" AS "SITENAME"
FROM "IT220_SITEDETAILS" "IT220_SITEDETAILS",
"IT220_LOOKUP_SITEHOLIDAY" "IT220_LOOKUP_SITEHOLIDAY",
"IT220_DIFFDETAILS" "IT220_DIFFDETAILS",
"IT220_HOLIDAYDETAILS" "IT220_HOLIDAYDETAILS"
WHERE UPPER("IT220_HOLIDAYDETAILS"."DIFFRATING") = UPPER("IT220_DIFFDETAILS"."DIFFCODE")
AND UPPER("IT220_HOLIDAYDETAILS"."HOLCODE") = UPPER("IT220_LOOKUP_SITEHOLIDAY"."HOLCODE")
AND UPPER("IT220_LOOKUP_SITEHOLIDAY"."SITECODE") = UPPER("IT220_SITEDETAILS"."SITECODE")
AND UPPER("IT220_SITEDETAILS"."SITENAME") = UPPER("IT220_DIFFDETAILS"."DIFFDESCRIP")
AND UPPER("IT220_DIFFDETAILS"."DIFFDESCRIP") NOT IN('EASY','MODERATE')Regards,
Jari -
Copy from column to another column in same table
Hi,
Working on EBS Version : 11.5.10.2
Table Name : ASO_QUOTE_HEADERS_ALL
COLUMNS :
QUOTE_STATUS_ID NUMBER
ATTRIBUTE6 VARCHAR2(240 BYTE);
Need to copy from quote_status_id to attribute6 for that quote_header_id
example if quote_status_id = 10 then it should copy in attribute6 = 10 for quote_header_id = 69312
again if changed to quote_status_id = 10077 then it should replace with attribute6 = 10077
for quote_header_id = 69312
i wrote a procedure posted below:
CREATE OR REPLACE procedure SLC_STATUS_CAPTURE (p_quote_header_id IN number) is
BEGIN
UPDATE aso_quote_headers_all SET attribute6 = quote_status_id
WHERE quote_header_id = p_quote_header_id;
end SLC_STATUS_CAPTURE;
then calling this trigger through table level
BEGIN
SLC_STATUS_CAPTURE(:OLD.QUOTE_HEADER_ID);
END;
it is giving an error.
Please i need some help.
Thanks and Regards
VijayJohn Spencer wrote:
As others have mentioned, you cannot change column values in a statement level trigger. Also, you cannot
update the table that the trigger is firing on. If I understand correctly, you want to copy the value of
quote_status_id into attribute6 whenever a row is inserted or updated. If that is correct, then you only need a simple trigger like:
create trigger trigg
before insert or update of aso_quote_headers_all
for each row
begin
:new.attribute6 = :new.quote_status_id;
end;Thought why anybody would want to do this is beyond me - you already have the info
in your attribute6 column - what's the point in simply copying it to another column in
the same table?
Paul...
John -
Sql join on two tables where column like another column
hi all,
been trying to get the results from a join between two tables where one column is like another one.
table1 (nameA) examples: black2, green1
table2 (nameB) example: black2.location.uk.com, green1.location.uk.com
so for example I want to match all those in table1 with black2 to the column in table2 that begins with black2 and so on if you see what im trying to get at!
my sql so far:
select * from schema.table1 a
join schema.table2 b
on a.nameA like concat('%', b.nameB, '%'); but it errors:
ORA-00909: invalid number of arguments
00909. 00000 - "invalid number of arguments"
Any help or advice would be greatly appreciated, thankyou!Either of these should do it...
select * from schema.table1 a
join schema.table2 b on a.nameA like '%'||b.nameB||'%';or
select * from schema.table1 a
join schema.table2 b on instr(b.nameB,a.nameA) > 0 -
Plotting Time Stamp from Txt file in Column to another column
I want to know how to plot 2 columns that i am reading from a text file.
column 1 has a time stamp in HH:MMS, and column 5 has data in which i want to plot the time verus the data.The Scan from String function will do most of those conversions in a single step. Here are a couple of examples. You will still need to read the array of strings in and process in a loop.
Message Edited by DFGray on 03-19-2010 07:46 AM
This account is no longer active. Contact ShadesOfGray for current posts and information. -
Printing the totals of 1 column under another column
Hi all,
I have an internal table with 3 fields A, B, C .
I want to print the subtotal of the column 'C' under the column 'A'.
eg:
Material_Group Matnr Cost
MG1 M1 C1
MG1 M2 C2
(C1 + C2)
(This should come under the column "Material_Group" instead of the column "Cost" )
Hope that the requirement is clear. Please help me out in this ..
Thanking you in advance,
Shankara Narayanan T.VHi,
Please use the 'At New' command to get the new material group. take the sum in a variable and use the write statement as shown below.
Write:/ sum under 'Material_group'
Thanks,
Ajith V -
Access datagrid column from another column
Hello
Basically, I have 2 columns in a DataGrid, both with CheckBox itemRenderers.
When I check the first checkbox, I want the second to be enabled = false. I'm stuck.
Thanks!This answers your question:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import mx.collections.ArrayCollection;
[Bindable] private var ac:ArrayCollection = new ArrayCollection([
{oneSelected: false, twoSelected: false, twoEnabled: true},
{oneSelected: false, twoSelected: false, twoEnabled: true},
{oneSelected: false, twoSelected: false, twoEnabled: true},
{oneSelected: false, twoSelected: false, twoEnabled: true}
public function changeEnabled(evt:ListEvent):void{
var origData:Object = ac.getItemAt(evt.rowIndex);
origData.twoEnabled = origData.twoEnabled == false?true:false;
ac.setItemAt(origData, evt.rowIndex);
]]>
</mx:Script>
<mx:DataGrid dataProvider="{ac}" itemClick="changeEnabled(event)">
<mx:columns>
<mx:DataGridColumn dataField="oneSelected">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox selectedField="oneSelected"
change="onChange(event);" label="">
<mx:Script>
<![CDATA[
private function onChange(evt:Event):void {
data.oneSelected = !data.oneSelected;
]]>
</mx:Script>
</mx:CheckBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="twoSelected">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox selectedField="twoSelected"
change="onChange(event);" label="" enabled="{data.twoEnabled}">
<mx:Script>
<![CDATA[
private function onChange(evt:Event):void {
data.twoSelected = !data.twoSelected;
]]>
</mx:Script>
</mx:CheckBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>
If this post answers your question or helps, please mark it as such.
Greg Lafrance - Flex 2 and 3 ACE certified
www.ChikaraDev.com
Flex / AIR Development, Training, and Support Services -
Filter column based on another column - OBIEE 11g
Hi, I have kind of a strange requirement. I'm trying to build a dashboard that lets a user see data for the current day, last week, last month, or last year. I'm going to create a presentation variable called "date_range" where the user can choose one of those 4 options.
Based on this, I've defined a column in answers with the following formula:
cast
case
when 1 = 0 then "Query Time"."Date"
when @{date_range}{'Day'} = 'Day' then Current_Date
when @{date_range}{'Week'} = 'Week' then TIMESTAMPADD(SQL_TSI_DAY, -7, CURRENT_DATE)
when @{date_range}{'Day'} = 'Month' then TIMESTAMPADD(SQL_TSI_DAY, -30, CURRENT_DATE)
when @{date_range}{'Day'} = 'Year' then TIMESTAMPADD(SQL_TSI_DAY, -365, CURRENT_DATE)
else TIMESTAMPADD(SQL_TSI_DAY, -10000, CURRENT_DATE)
end as DATE
Based on the 4 presentation variable, this should give the proper "start date" of when to pull data.
Now I've added the actual date column from the date dimension. But I need to put a filter on the date dimension date column that says it's greater than or equal to the calculated column above. How do I do that?
Thanks,
ScottI always expect what you're expecting, but you can't filter a column on another column. The solution is just to write one formula that returns a literal, so it will be
case when (your date column) >= (your long formula) then 'Y' else 'N' end
Then filter that column on 'Y'.
Regards,
Robert -
How to pass column name as a values from one page to another
hi
i have created a report(pivot) from a table
SQL> SELECT * FROM T;
C1 C2 C3 D SEQ
A AA 2 1
A AB 3 2
A AC 2 3
B AB 5 4
B AC 6 5
SQL> SELECT C1
2 ,NVL(MAX(CASE WHEN C2='AA' THEN C3 END),'') AA
3 ,NVL(MAX(CASE WHEN C2='AB' THEN C3 END),'') AB
4 ,NVL(MAX(CASE WHEN C2='AC' THEN C3 END),'') AC
5 ,SUM(C3) FROM T GROUP BY C1;
C1 AA AB AC SUM(C3)
A 2 3 2 7
B 5 6 11
SQL>
my requirement in Apex is like this(reverse)
eg-
when i click on cell values '2' then,it should return
C1 C2 C3 D SEQ
A AA 2 1
{quote}how to pass column name as a values from one page to another
for example i have to pass 'c2' as a value to next page{quote}for report pivot you can reffer below link
Report
Amuthanks for your reply
i 'm doing what exactly you mention here .
my problem here is
i have 15 columns
i am executing a query based on the values of the column(column name) in the target page
1)here i am passing(all) the column values to the next page-but i want to pass only one column values(column name)
when i click on any cell of that column
OR
2)i can pass all column name to target page -there(in the target page) i can filter out
i think option 1 would good if you filter out the unwanted columns
Regards
Amul -
How can I Move data from one column to another in my access table?
I have two columns, one that stores current month’s data and one that stores last month’s data. Every month data from column 2 (this month’s data) needs to be moved to column 1 that holds last month’s data. I then null out column 2 so I can accumulates this month’s data.
I understand how to drop a column or add a column, how do I transfer data from one column to another.
Here is my trial code:
<cfquery name="qQueryChangeColumnName" datasource="#dsn#">
ALTER TABLE leaderboard
UPDATE leaderboard SET points2 = points3
</cfquery>
Unfortunately, I get the following error:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in ALTER TABLE statement.
How can I transfer my data with the alter table method?I looked up the Access SQL reference (which is probably a
good place to start when having issues with Access SQL), and
it suggests you probably need a WHERE clause in there.
I agree the documentation is a good place to start. But you should not need a WHERE clause here.
Too few parameters. Expected 1.
If you run the SQL directly in Access, what are the results? At the very least, it should provide a more informative error message.. -
Update column in one table from another
I've got two tables:
t1:
con_num
con_code
ex
elin
addressee
a few other columns
t2:
con_num
con_code
elin
addressee
contact
a few other columns
I just got about 300 rows into t2 using sqlloader, and now I need to use t2 to update t1. t1 will have 3 rows per ex||elin, but t2 can have more or less rows per elin (which is the same as ex||elin in t1). If t2 has 4 rows per one elin, then that is 4 distinct pieces of data, and I need to make sure that t1 reflects 4 rows in its ex||elin, each containing the addressee||contact from t2. So I'll need to add a row to t1, as well as update 3 rows. Is this possible with just SQL, or do I need to write PL/SQL?
The following is the code I've been trying:
update t1
set t1.addressee =
(select addressee from t2
where t2.con_num = 'number'
and t1.con_code = t2.con_code
and t1.ex ||t1.elin_num = t2.elin_num)
This code is not correct, it returns more than one row from t2. Also, I'd need to concatenate contact onto addressee with a space in the middle, not just addressee, into t1.addressee.
Any ideas, pointers?
Thanks!Forgot some info: Ora8.1.5 on win2kpro. Also, I was wanting to combine addressee||contact in the insert/update statement to differentiate one addressee from another in t1 after the data is inserted. We can have several addressees that are the same, but each one goes to a different contact for each record.
Thanks!
Maybe you are looking for
-
I updated my spouses phone using the same apple id. I must have clicked ok to something i shouldnt have at some point.....because now he is recieving my texts! I still recieve my texts, but he also recieves them. I went to restore his phone but it sa
-
How Do I Set a Default Calendar for New Appointments in iCal?
I have two calendars in iCal. How can I set one to be the default when I create new appointments?
-
Hi, I have to display per page the following information: - customeraddress (name, street, postcode, country) - articles( this is a table which can contain 1 or more articles) The page can be extended to 2 pages. And the complicated thing is that Cus
-
Regarding display of Account Number in Report Writer Report
Hi All, I am working on Report Writer Report. It is related to Dipslay of Account Numbers with their corresponding description. My Issue is On the output screen I am able to see only the Description of Account Numbers. But I need to <b>Display the Ac
-
No icons on my desktop or the taskbar after 5 different delete/downloads
after loading firefox onto my new dell 17r i noticed there were no icons either on my desktop or my start menue. i deleted it and tried again. 5 times. to no avail. what gives? ive never had this problem before?