How to group rows based on a formula value
Hi experts,
I have a query that returns a a char row (country) and a couple of columns, "Duration of Process in days" and "Counter of nº process done", each a calculated formula KF .
What I would like is to group the results based on formula KF1 results ""Duration of Process in days".
For example: from this query result
Country - Duration of Process in Days - Counter of nº process done
ES 1 3
PT 3 2
UK 4 3
IT 1 5
US 6 2
FR 1 3
DE 4 5
get the following: aggregated by all possible formula values "Duration of Process in Days"
Duration of Process in Days - Counter of nª process
1 11 (353)
3 2
4 8 (3+5)
6 2
Is this possible??
Thanks in advance for your help,
Best regards,
Enric
Hi Vikram,
my problem is that the "Duration in days" cannot be a characteristic derived in the loading process, as its value depends (is calculated) based on several user's selections done in the variable pop-up screen when executing the report.
Thanks again for your reply.
Enric
Similar Messages
-
How to HIde rows based on User Selection
I have a requirement where in I have to hide some rows based on Plant Name selected by USer at the time of opening the report.
Here is the screen shot:-
Here I am seeing two Tag Types MACT and Average when User selects Luling Plant. But When User selects some other Plant I don't want to see Tag Type 'MACT' in this table.
We have a predefine filter for Plant.
How can I achieve that. The data in White Rows is Average values.
Please help.
RegardsHi Shalini,
Is user selecting Plant Name from the report prompt. If Yes, then try below-
Create a variable-
FilterSelect= If UserResponce("WritePromptTextHere") =" Luling Plant" and TagType inList ("MACT";"Average") Then 1 ElseIf UserResponce("WritePromptTextHere") <>" Luling Plant" and TagType inList ("MACT";"Average") Then 3 Else 2
Apply Filter on "FilterSelect" variable-
FilterSelect=1 and 2
~Anuj -
How to build LOV based on colon deliminated values in table?
Hi All,
I have a CUSTOMERS table with a column TYPES. This column stores colon deliminated values coming from a standard shuttle element eg.:
CUSTOMER_NAME TYPES
Customer 1 1:2:3
Customer 2 2:3:4I need to build a query which will return me all types (as rows) based on a given customer, Eg. in the above example, for Customer 1 I should have something like:
CUSTOMER_NAME TYPE
Customer 1 1
Customer 1 2
Customer 1 3Any ideas?I have a set of examples showing how to do that here:
http://apex.oracle.com/pls/otn/f?p=31517:84
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------------------ -
Need to color a Table row based on a Column value
Dear Alll
I have a requirement to color the rows of a table based on a column value in it. I have tried and surfed many useful materials over the net. but none of them solves my purpose. Please help me, I know that i can used OADataBoundValueViewObject and create a custom css file and apply color to a particular column of a table using a decode in the select statement of that VO.
But all i need is to color a particular row with a particular color. Need your help with this ........
Please do reply
Best Regards
Edited by: Antony Jayaraj on Mar 27, 2012 8:54 PMThese posts might help you.
How to change the row color based on Condition
Can we colour the rows in the column of a table
Regards,
Peddi. -
Formating the Row Based on one column value
Hi Friends
I am trying to format the Entire row based on the value of the first column in my Answers.
Example if first column value in 'F' now i want the Entire row to be colored
I can do conditional formating on one column but i want to do it on the entire row
F 8.1 % 12.0 %
E 5.2 % 3.5 %
M 2.3 % 3.3 %
If any one has done this or any suggestions please respond
Thanks
SangIts a Pivot View
F 8.1 % 12.0 %
E 5.2 % 3.5 %
M 2.3 % 3.3 %
the column 1 --> F,E,M are the Product
the column 2 --> 8.1% , 5.2% , 2.3% are the sales in year 2008
the column 3 --> 12.0 % , 3.5 %, 3.3 % are the sales in year 2009
So will i be able to apply the formating in pivot view based on one column to other column If yes please let me know how or
suggest if this can be done using the BI Office , or BI publisher
sing the BI Office i can do the formating in Excel but once i refresh the data all the formating is gone ... :(
I am donno BI Publisher if we have to use BIP please suggest any solution its very very very urgent and important report formating they need here ....
Thanks in advance David
sango -
Move row based on one duplicated value
is it possbile to move entire rows base on just the value in the first column?
1 a
1 b
2 c
2 d
the result should be
1 a
2 cYes - double the header row, then use a formula like the one that I posted but start in row 1, with the formula
=COUNTIF($A$1:$A1,$A1)
Then copy down, copy that column, paste as values, and finally, sort the entire table
based on that value. Then List1 will all have 1s in that column, List2 will have 2s, etc. -
How to retrieving latest row based on a column value
Hi,
Lets consider a scenario. I have a table which has a order number, count column which is our fact, a type column which contains types e.g. (A,B) with A has more priority then B. Now in our graph we are getting all rows i.e. if we have two rows in db for order #1 one for type A and one for type B, then it shows us data from both rows in graph.
But I need only to show one row of type A in this case as A has higher priority than B. The row with type B should not contribute in construction of my graph if type A for same row also exists.
I tried a solution, for which i created a new column at logical level which contain 1 for A and 0 for B. Now i put Max aggregation rule in it to get maximum value which will be row with Type A in our case. But it did not work.
How we will can achieve it in OBIEE?
Thanks.
Aasim Khan.Hi Steve,
I have a similar requirement... one of the columns in my table is a calculated value based on several xml fields,
<?xdofx:(MATH01+MATH02+MATH03+MATH04+MATH05+AA+AA1)+((FNDCD01+FNDCD02+FNDCD03+FNDCD04+FNDCD05+MCHCD01+MCHCD02) div '8')?>
if the resultant value above is less than 62, i do no want to display this entire row in the output. could you help me wout with this?
thanks
Domnic -
How to select rows based on values from other table?
I need to select all rows from TABLE1 whose time column is NOT between fromTime and toTime from TABLE2.
For example, those table contain following rows:
TABLE1
|id |time |...
|1 | 10 |...
|2 | 20 |...
|... | ... |...
TABLE2
|fromTime|toTime|
| 3 | 6 |
| 10 | 16 |
| 20 | 25 |
So, in the case above the first and second rows shouldn't be returned by the query since 10<=10<=16 AND 20<=20<25.Try
-- code #1
SELECT id, time
from TABLE1 as T1
where not exists (SELECT * from TABLE2 as T2
where T1.time between T2.fromTime and T2.toTime);
José Diz Belo Horizonte, MG - Brasil -
How to group data based on date
In my program the internal table is returning several values based on date.
for example for the first pernr in the image below there are four records. i need to delete the first record which is between the dates 20 and 30 .
and also i need to get the difference between the dates as the record 23 and 28 i need to get separate dates as 24, 25..28.I am not sure if I understood your question correctly.
From what I have understood, you can use the following logic.
This logic will move all the records from lt_fields2 to another table lt_fields1 with begda between 20 and 30 of any month, except for the first record. It will also move records for every date between begda and endda of each record.
You can alter the logic based on your exact requirement.
declare another table lt_fields1 like lt_fields2.
data del_flag.
data prev_month(2) type c.
sort lt_fields by pernr begda.
clear del_flag.
loop at lt_fields2 into wa_fields where begda+6(2) GE 20.
* Delete the first record having date greater than 20 in a month for each pernr.
at new pernr.
clear del_flag.
endat.
if begda+4(2) NE prev_month.
clear del_flag.
endif.
if del_flag is initial.
del_flag = 'X'.
continue. " This record will not be moved to the final internal table.
endif.
* Add records for each date between begda and endda.
append wa_fields to lt_fields1.
prev_month = begda+4(2)
while wa_fields-begda LT wa_fields-endda.
wa_fields-begda = wa_fields-begda+1.
append wa_fields to lt_fields1.
endwhile.
endloop. -
How to repeat rows based on column value
Hi all,
I have a query that gives me a result with a column value for example 4.
I now want to repeat this row 4 times with a new column that calculated from 1 - 4.
Or when column value is 3 I want to repeat row 3 times with new column name 1-3
Can anyone help me with this please? :)Hi Yvanlathem,
To achieve your requirement, you can reference the recursive approach as below.
DECLARE @T TABLE(Col1 CHAR(1),Col2 INT)
INSERT INTO @T VALUES('A',1),('B',2),('C',3)
;WITH Cte([Char],[Repeat]) AS
SELECT Col1,Col2 FROM @T
UNION ALL
SELECT [Char],[Repeat]-1 FROM Cte
WHERE [Repeat]>1
SELECT * FROM Cte ORDER BY [Char],[Repeat]
OPTION(MAXRECURSION 0)
/* Output
Char Repeat
A 1
B 1
B 2
C 1
C 2
C 3
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
How to split rows based on two columns..
Hi all...
I have a requirement.
I have product column, sell, purchace prices..(total of three columns) in a data set.
my data set is such a way that..if sale price exists...there is no purchase price and vice versa..
I need too present in a report ,two tables:
table 1 consists of only Sale price items
table 2 should contain only Pruchase Items.
Please see the below picture for clear understanding..
Is that doable? Where do we need to impose a condition?I tried to impose a condition but,it didnt seem to work
http://i51.tinypic.com/29xfdc6.jpg
Please help.Can you send me the template and xml file to [email protected]? I can try to help.
Did you try to filter out the records by the sale price or purchase price column not equal to null?
Thanks,
Bipuser -
Update a row based on the minimum value
I need to update a row value in a table (table1) which is having one-to-may relationship with another table (table2) based on priority. Below is the table structure and sample data. I have a merge statement which can just do this, but it's taking too much to execute if the data in table2 is huge.
I want to reduce the execution time, can anyone suggest me another way to do this.
--Table Definition
CREATE TABLE TABLE_1 (ENAME VARCHAR2(20), ID NUMBER(20), DISPLAY_NAME VARCHAR2(20), PRIMARY KEY (ENAME));
CREATE TABLE TABLE_2 (ENAME VARCHAR2(20), DISPLAY_NAME VARCHAR2(20), PRIORITY NUMBER(1));
--Sample data
INSERT INTO TABLE_1 (ENAME,ID) VALUES ('EMP1','1000');
INSERT INTO TABLE_1 (ENAME,ID) VALUES ('EMP2','2000');
INSERT INTO TABLE_2 (ENAME,DISPLAY_NAME,PRIORITY) VALUES ('EMP1','APPLE',1);
INSERT INTO TABLE_2 (ENAME,DISPLAY_NAME,PRIORITY) VALUES ('EMP1','DELL',2);
INSERT INTO TABLE_2 (ENAME,DISPLAY_NAME,PRIORITY) VALUES ('EMP1','MS',NULL);
--Merge to perfor the update
MERGE INTO TABLE_1 T USING
(select ename, display_name from TABLE_2 where (ename,priority) in (
select distinct ename, min(priority) over (partition by ename) from TABLE_2 min_prior)) Q
ON (T.ENAME = Q.ENAME)
WHEN MATCHED THEN UPDATE SET DISPLAY_NAME = Q.DISPLAY_NAME;Hi,
You can use the aggregate FIRST function, like this:
MERGE INTO table_1 t
USING (
SELECT ename
, MIN (display_name) KEEP (DENSE_RANK FIRST ORDER BY priority)
AS first_display_name
FROM table_2
GROUP BY ename
) q
ON (t.ename = q.ename)
WHEN MATCHED THEN UPDATE
SET t.display_name = q.first_display_name
;If the combination (ename, priority) is not unique in table_2, then this uses the first display_name (in normal sort order) among those with the lowest priority. This probably can't happen, becuase your original statement would raise an error if it did.
For performance problems, see the forum FAQ {message:id=9360003} -
I'm dealing with an old database that's being phased out, and here's the version info (yes, it's really old):
Oracle8i Enterprise Edition Release 8.1.7.2.0 - Production
PL/SQL Release 8.1.7.2.0 - Production
CORE 8.1.7.0.0 Production
TNS for HPUX: Version 8.1.7.2.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
I believe Frank Kulash gave me the solution to my original question, which was:
Sample data:
CREATE TABLE testabc
( item CHAR(25)
, qty NUMBER(13,4)
INSERT INTO testabc
VALUES ('Item1',1);
INSERT INTO testabc
VALUES ('Item2',3);
INSERT INTO testabc
VALUES ('Item3',1);
INSERT INTO testabc
VALUES ('Item4',2); Desired results:
ITEM QTY
Item1 1.000
Item2 3.000
--blank row
--blank row
Item3 1.000
Item4 2.000
--blank rowAnd the solution:
SELECT CASE
WHEN c.n = 1 THEN t.item
END AS item_col
, CASE
WHEN c.n = 1 THEN t.qty
END AS qty
FROM testabc t
SELECT ROWNUM AS n
FROM all_objects
WHERE ROWNUM <= 10 -- If you know an upper bound
) c
WHERE c.n <= t.qty
ORDER BY t.item
, c.n
;Now, it turns out there are only some items which need these extra rows, but I'm not sure if it's possible to only include extra rows for certain items or not...
Here's my new sample data:
CREATE TABLE testabc1
( s CHAR(1)
, item CHAR(25)
, qty NUMBER(13,4)
INSERT INTO testabc1
VALUES ('*','Item1',1);
INSERT INTO testabc1
VALUES ('','Item2',3);
INSERT INTO testabc1
VALUES ('*','Item3',3);
INSERT INTO testabc1
VALUES ('*','Item4',2);And my new desired results: (any row with an asterisk gets extra rows, if the qty is greater than 1)
S ITEM QTY
* Item1 1.000
Item2 3.000
* Item3 3.000
--blank row
--blank row
* Item4 2.000
--blank rowEdited by: user11033437 on Jan 3, 2012 9:27 AM (fixed missing asterisk in desired results)Hi,
Here's a slightly simpler way:
SELECT CASE
WHEN c.n = 1 THEN t.item
END AS item_col
, CASE
WHEN c.n = 1 THEN t.qty
END AS qty
FROM testabc1 t
SELECT ROWNUM AS n
FROM all_objects
WHERE ROWNUM <= 10 -- If you know an upper bound
) c
WHERE c.n <= CASE
WHEN t.s = '*'
THEN t.qty
ELSE 1
END
ORDER BY t.item
, c.n
;This is just like the previous solution, except that the WHERE clause, which was originally
WHERE c.n <= t.qtyis now
WHERE c.n <= CASE ... END
user11033437 wrote:... And my new desired results: (any row with an asterisk gets extra rows, if the qty is greater than 1)
S ITEM QTY
* Item1 1.000
Item2 3.000
Item3 3.000
--blank row
--blank row
* Item4 2.000
--blank row
S should be '*' on the output row where item='Item3', right?
I'm sure you know how to get the s column in the output, but, since I've already tried it:
SELECT CASE
WHEN c.n = 1 THEN '*'
END AS s
, CASE
WHEN c.n = 1 THEN t.item
END AS item_col
, CASE
WHEN c.n = 1 THEN t.qty
END AS qty
FROM testabc1 t
SELECT ROWNUM AS n
FROM all_objects
WHERE ROWNUM <= 10 -- If you know an upper bound
) c
WHERE c.n <= CASE
WHEN t.s = '*'
THEN t.qty
ELSE 1
END
ORDER BY t.item
, c.n
;Edited by: Frank Kulash on Jan 3, 2012 11:11 AM -
Adding a row based on a total value
I have the following table
tablea
AnID
Aname
aTotal
57
Agatha
28
58
Bertie
13
59
Guilford
17
60
Francois
12
I want to be able to create a query that displays the id aname atotal and also another column called noofrows. I would like the query to list multiple records for each AnId based on the atotal / 14 e.g. if the aTotal equals 28 then there will be two
rows for Anid 57 and the Noofrows column will display a1 and a2. If there result is less than 14 and greater or equal to 1, the total rows must be 1. If the total is 0 then the rows will be 0. See below the results of this example
AnID
Aname
Total
Noofrows
57
Agatha
28
a1
57
Agatha
28
a2
58
Bertie
13
a1
59
Guilford
56
a1
59
Guilford
56
a2
59
Guilford
56
a3
59
Guilford
56
a4
60
Francois
80
a1
60
Francois
80
a2
60
Francois
80
a3
60
Francois
80
a4
60
Francois
80
a5
60
Francois
80
a6
Can anyone help?This was a fun one. This should work for you.
--drop table #temp
create table #temp
AnID int,
Aname varchar(10),
total int
insert into #temp(AnID, Aname, total) values ('57','Agatha','28')
insert into #temp(AnID, Aname, total) values ('58','Bertie','13')
insert into #temp(AnID, Aname, total) values ('59','Guilford','56')
insert into #temp(AnID, Aname, total) values ('60','Francois','12')
; WITH CTE (CT,AnID, Aname, Total, Rw)
as
select
1 as CT,
t.AnID,
t.Aname,
t.total,
SUM(t.total/14) over (partition by t.AnID, t.Aname order by t.total) as rw
from #temp t
UNION ALL
select
CT + 1,
t.AnID,
t.Aname,
t.total,
SUM(t.total/14) over (partition by t.AnID, t.Aname order by t.total) as rw
from #temp t
inner join cte c
on c.AnID = t.AnID
where ct <= (rw-1)
select
AnID,
Aname,
total,
'a' + cast((row_number() over (partition by AnID, Aname, Total order by total)) as varchar(10)) as Noofrows
from cte -
Hide or delete row based on it's value?
If I have a column called "Name" and I want to delete or hide all the rows which include the name "smith" or alternatively all the rows with "Miss" how do I do this?
I know I can manually search to find the name "smith" but I have 60,000+ rows in my spreadsheet.
Format:
Column 1
Row 1: Miss J Jones
Row 2: Mr P Smith
Row 3: Mr C Widget
etc...
Thanks.Here is an AppleScript whic is able to delete the rows matching your criteria.
--[SCRIPT removematchingrows]
Enregistrer le script en tant que Script : removematchingrows.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Sélectionner une cellule de la colonne dans laquelle le script cherchera le mot clé.
menu Scripts > Numbers > removematchingrows
Tapez le mot à chercher puis cliquez OK.
Le script supprimera les lignes dont la cellule de la colonne sélectionnée contenait le mot saisi.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
--=====
Save the script as a Script: removematchingrows.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select a cell in the column in which we will search a key word.
menu Scripts > Numbers > removematchingrows
You will be asked to type the word to search.
Type it then click OK.
The script will remove the rows whose the cell of the selected column contained the choosed word.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
--=====
Yvan KOENIG (VALLAURIS, France)
2010/03/24
--=====
on run
if my parleAnglais() then
set theKey to text returned of (display dialog "Enter the word to search …" default answer "At least one cell of the column in which we will search must be selected.")
else
set theKey to text returned of (display dialog "Saisir le mot à chercher …" default answer "Une cellule de la colonne dans laquelle il faut chercher doit être sélectionnée.")
end if
set {dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
set nbRows to row count
repeat with r from nbRows to 1 by -1
set maybe to (value of cell r of column colNum1) as text
if words of maybe contains theKey then
remove row r
end if
end repeat
end tell -- Numbers
end run
--=====
on getSelParams()
local r_Name, t_Name, s_Name, d_Name, col_Num1, row_Num1, col_Num2, row_Num2
set {d_Name, s_Name, t_Name, r_Name} to my getSelection()
if r_Name is missing value then
if my parleAnglais() then
error "No selected cells"
else
error "Il n'y a pas de cellule sélectionnée !"
end if
end if
set two_Names to my decoupe(r_Name, ":")
set {row_Num1, col_Num1} to my decipher(item 1 of two_Names, d_Name, s_Name, t_Name)
if item 2 of two_Names = item 1 of two_Names then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
set {row_Num2, col_Num2} to my decipher(item 2 of two_Names, d_Name, s_Name, t_Name)
end if
return {d_Name, s_Name, t_Name, r_Name, row_Num1, col_Num1, row_Num2, col_Num2}
end getSelParams
--=====
set {rowNumber, columnNumber} to my decipher(cellRef,docName,sheetName,tableName)
apply to named row or named column !
on decipher(n, d, s, t)
tell application "Numbers" to tell document d to tell sheet s to tell table t to return {address of row of cell n, address of column of cell n}
end decipher
--=====
set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
on getSelection()
local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
tell application "Numbers" to tell document 1
set nbCols to column count
repeat with i from 1 to the count of sheets
tell sheet i
set x to the count of tables
if x > 0 then
repeat with y from 1 to x
try
(selection range of table y) as text
on error errMsg number errNum
set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
return {theDoc, theSheet, theTable, theRange}
end try
end repeat -- y
end if -- x>0
end tell -- sheet
end repeat -- i
end tell -- document
return {missing value, missing value, missing value, missing value}
end getSelection
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]
At this time, I don't know how to Hide a row thru AppleScript.
Yvan KOENIG (VALLAURIS, France) mercredi 24 mars 2010 17:02:20
Maybe you are looking for
-
I have been having a very weird problem with mail since the last few weeks. I pop my email from gmail and I have usual folders and some basic rules. The new mails (as well as some read ones) keep disappearing from the Inbox. But they showup again whe
-
MY new Mac book pro will not save any of teh bookmarks I make in safari. If I make a bookmark, it will not appear until I close safari and reopen it. Then, if I shut my computer down and reopen safari, all of the bookmarks are gone. This has happend
-
Need to add link to report library on quick launch
I hid the "Report Library" quick launch link on the left hand side of the Sharepoint portal home page, and then was informed that it needed to be displayed again .I selected "Yes" for "Display this document library on the Quick Launch?" when setting
-
My wireless apple mouse randomly disconnects while I'm using it?
Brand new batteries. I'll be sitting there using it, and it just stops responding. The computer still shows that the mouse is connected, but I have to go with the track pad and disconnect, then reconnect it again. Then it works. It's not a big deal u
-
Error code 1064 mysql and crystal reports XI
Post Author: aminski CA Forum: Data Connectivity and SQL Hello friends , I am trying to create a Crystal Report connected to a MySQL database using an ODBC (RDO) connection. I created a DSN using the MySQL Connector/ODBC 3.51 and mysql database 3.23