Insert a footer row outside child column group
Hi All,
I am using a tablic in which I have used a parent and child colgroup.When I added the parent col group then it created a row with the col group(Expression is like =Ceiling(Fields!ColNo.Value/3)) . After that I added the child group(Expression is ColNo).
This group is applying on the subsequence columns. Then the out put comes in the expected way. But the problem is I need to add a new row in the end of talix as footer with parent group. If I try to add then it is always adding in the child group.
Any Suggessions?????????
Regards, MRAPAKA
Hi MRAPAKA,
In Reporting Services, we can add or delete rows in a tablix data region. In a tablix data region, we can add rows that are associated with a group (inside a group) or that are not associated with a group (outside a group).
When we add a row inside a group, a row that is inside a group repeats once per unique group value, and the added row will be close to the group. So in your scenario, if we click the last row to add a row (inside a group), then it will become the part of
child group. This should be make sense. If we want to add a row as the part of parent group, we can refer to the suggestion posted by Visakh. Then the row will be added after the parent group, other than the last row in the tablix. This is by design.
Thank you for your understanding.
Regards,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Similar Messages
-
Dynamic footer row prints outside the content area
Hi,
I'm using LiveCycle Designer ES 8.2.1. I also have a web application injecting data into the report I created with LiveCycle. The basic structure is the following:
1 Master page with 1 page and a content area containing a table filled with a list of object. My table has 1 header row, 2 body rows and a footer row that is added dynamically with page break condition.
The logic behind that is written in FormCalc. Our objects are sent as a list which fills either one or the other body row based on a type. Each object has an "authority" property with a certain value that are used to mark the pages. The list of object is sorted by authority. So, when the current iterating object has a different authority than the previous one, we insert a page brake and the footer row. Everything is wraped in a subform that is "In Content Area" (Object/Pagination/Place).
The problem is that the footer row is not considered as part of the content area. If the last line of a section fits tight in the content area, the footer row overflows outside the content area and even the whole page in some cases.
Here are more details:
We tried any combination of subform wraping and ticking of the "Allow page break with content" check box.
We tried changing the type of the footer row for a body row in case footers were different than body rows.
We tried every combination of "Keep with" and "place".
We tried to change the footer row to a body row and have it displayed on every page and that work, but our client refused the solution...
Starting with the above (pt 4) template and changing back the body to footer row brought us to the begining
To the best of our knowledge, we tried everyting possible...
What I'm looking for is either a confirmed bug for version 8.2.1 about this or a solution other than redesigning the whole report.
Best regards,
Sylvain CloutierHi,
I know this might no help to solve my issue, but this document doesn't belong to me and I'm afraid I cannot share the file on the internet. It belongs to our client to whom we offer support on this. You know... I'd probably lose my job!
Though, I've been trying with Adobe LiveCycle Designer ES4 11.0.0 and the same problem occurs. It looks like the row is added to the table after the whole document was produced, so it seems to be working as designed. -
Previous record values displaying in the Group Footer row in the report.
Hi Friends,
I have 3 tables
TableA:(PERNR BEGDA ENDDA are key fields)
PERNR BEGDA ENDDA WERKS
10001 1/1/2010 12/31/9999 1001
TableB:(PERNR BEGDA ENDDA SUBTY are key fields)
PERNR BEGDA ENDDA SUBTY TYPES
10001 1/1/2010 12/31/9999 01 COMS1
10001 1/1/2010 12/31/9999 02 COMS2
TableC:(PERNR BEGDA ENDDA are key fields)
PERNR BEGDA ENDDA AMNT
10001 2/2/1997 4/3/2010 1000
10001 4/4/2010 12/31/9999 2000
I have joined these table by the key 'PERNR'( like A->B and A->C)
Groped by the same key 'PERNR'
My result rows in the report:
PERNR BEGDA ENDDA WERKS SUBTY TYPES BEGDA ENDDA AMNT
10001 1/1/2010 12/31/9999 1001 01 COMS1 2/2/1997 4/3/2010 1000
10001 1/1/2010 12/31/9999 1001 02 COMS2 2/2/1997 4/3/2010 1000
10001 1/1/2010 12/31/9999 1001 01 COMS1 4/4/2010 12/31/9999 2000
10001 1/1/2010 12/31/9999 1001 02 COMS2 4/4/2010 12/31/9999 2000
But in the report format is like this in the Group Footer row:
PERNR: 10001 WERKS:1001
SUBTY: 02 AMNT :2000 (Current date)
AMNT :1000 (Previous record)
I created the format with "Previous" function
but in the report it is giving the '2000' instead of '1000' in the AMT field
Please help me, can i use the for loop in the report? or any sugessions?
Thanks in advance.
Regards,
VenkataA group footer will dis[lay contents of the last record. You need to sort records to ensure that the last record contains link to your dynamic image.
Ian -
Inserting a new row in a child table referencing an already existing parent
I have two tables PARENT & CHILD (one to many), both of which are populated at different times.
In our toplink mappings, parent contains a collection of child Domain Objects, & and child Domain object contains a one - one to parent.
How can I insert a new row in a child table with reference to an already existing row in parent?
When I fetch the parent Domain object and try to set it in the child Domain Object and use the unitOfWork.registerObject() it goes into a circular loop of selecting from 2 other tables.
Please suggest.Odd, have you disabled caching and indirection? (NoIdentityMap, dontUseIndirection, or alwaysRefresh/disableCacheHits). If so, then this could be the issue.
Otherwise please include the sample code you use to perform this, and verify that you do not have any unusual code in your set/get methods or in descriptor events. Also turn TopLink logging on and include a sample. Also ensure that you do not modify your objects until after registering them in the unit of work, and only modify the unit of work clones. -
Inserting multiple rows in child table
i have two entity beans (main and child) with relationship one to many .... when i insert one row in main table (ie when i make one object for main entity bean)... how to insert multiple rows in child table...
Can anyone pls provide some sample code for the above.. how to pass a collection and populate it in the child table.
1.Where to pass the collection, to the childbean directly or to the parent bean and then itereate to the collectio and create child bean.
Much obliged if you could paste some code for the above.. -
I am creating new table. My goal is to display some text in few lines like this:
"AAAAAAAA" "BBBBBBBB" "CCCCCCCCC"
"DDDDDDD" "EEEEEEEE"
Actually the next row (with "DD" and "EE" values) is not displayed below first row, but on the next page.
I've tried to put table into rectangle, disabled all page breaks and still the same effect. Any help?Hi Heidi,
Actually, it's not solution, I only gave more details about my problem :)
Another description:
In my report I'm creating Tablix with Column grouping. There is only one column with image (every image has same width). If there is only three pictures, then they are displayed next to each other in one row.
In case, there is more than three pics, another row is showing on next page. I'd like to display all rows one after another on one page.
I've tried to create three vertical lists, and filter each column group to display only records:
1) =(RowNumber("Tablix1")) mod 3 = 1
2) =(RowNumber("Tablix1")) mod 3 = 2
3) =(RowNumber("Tablix1")) mod 3 = 0
Unfortunately, I got an error:
"A FilterExpression for the tablix ‘Tablix1’ uses the function RowNumber. RowNumber cannot be used in filters."
Do You have any other propositions?
--------EDIT--------
ok, I manged to solve it. As I said, I've created three vertival lists and placed them next to each other.
Then, instead of using filter, I've used Visibility trigger:
1)
=IIf(RunningValue(Fields![rowgroupfield].Value, COUNTDISTINCT, "Tablix1") mod 3 = 1, false, true)
2)
=IIf(RunningValue(Fields![rowgroupfield].Value, COUNTDISTINCT, "Tablix2") mod 3 = 2, false, true)
3)
=IIf(RunningValue(Fields![rowgroupfield].Value, COUNTDISTINCT, "Tablix3") mod 3 = 0, false, true)
I had to use function RunningValue to count all occurrences, as my report is quite complex and "RowNumber" [ssrs function] and "ROW_NUMBER() OVER (ORDER BY [rowgroupfield])" [sql query] were not working properly. -
How to get the difference between two columns in a column group
Hi All,
My first time here and really new to programming. I would like to get the difference between 2 columns that are inside
a column group.
Here is my sample table below: The Column Group is PeriodNumber and can only choose 2. like 1 and 2.. I would like to have a third row which will simply calculate the difference between the amounts in PeriodNumber 1 and 2.
PeriodNumber
Account 1 2
1) Cash 10,000 15,000
2) Receivables 12,000 11,500
3) Equipment 5,000 5,500
Total Assets 27,000 32,000Hi yabgestopa,
From your description, you want to get the difference between two columns in a column group. After testing it in my environment, we can use custom code to achieve your requirement. For more details, you can refer to the following steps:
Copy the custom code below and paste it to your report. (Right-click report>Report Properties>Code)
Dim Shared Num1 As Integer
Dim shared Num2 As Integer
Public Function GetAmount(Amount as Integer, Type as String)
If Type = "1" Then
Num1=Amount
Else
Num2=Amount
End If
Return Amount
End Function
Public Function GetDif()
Return Num1-Num2
End function
Right-click the second column to insert a third column with Outside Group-Right.
Then use the expressions below in the matrix.
=Code.GetAmount(Fields!Amount.Value,Fields!PeriodNumber.Value)
=code.GetAmount(Sum(Fields!Amount.Value),Fields!PeriodNumber.Value)
=Code.GetDif()
The report looks like below.
If you have any questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How can i select some row from multiple row in the same group of data
I want to select some row from multiple row in the same group of data.
ColumnA
Column B
1 OK
1 NG
2 NG
2 NG
3 OK
3 OK
I want the row of group of
ColumnA if ColumnB contain even 'NG'
row , select only one row which Column B = 'NG'
the result i want =
ColumnA Column B
1 NG
2 NG
3 OK
Thank youThat's some awful explanation, but I think this is what you were driving at:
DECLARE @forumTable TABLE (a INT, b CHAR(2))
INSERT INTO @forumTable (a, b)
VALUES
(1, 'OK'),(1, 'NG'),
(2, 'NG'),(2, 'NG'),
(3, 'OK'),(3, 'OK')
SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
FROM @forumTable f
LEFT OUTER JOIN @forumTable f2
ON f.a = f2.a
AND f.b <> f2.b
GROUP BY f.a -
How to create RunningValue Through Column Groups?
Hi Everybody i´m trying to do this with a Matrix
I want the running value of the product quantity for each month of a year,
resetting the running value
when a new year is reached
I have 2 column groups "Year" and as it´s child group "Month".
2009
2010
January Febrary March January February March
Product
Toolbelt 10 15 20
1 10 50
Well that is the idea...
In the field of the quantity i´m using an expression like this = RunningValue(Fields!Quantity.Value, Sum, Nothing) .
With this expression i get the the running value and it´s great, but
it does not reset thru the years ,
it continues aggregating the quantity value.
So i tried with this expression assuming if i set the SCOPE to the Year group i can achieve this
= RunningValue(Fields!Quantity.Value, Sum, "Year") ,
But surprise!!, this is not giving me the right aggregation , i´m still dig in it and can´t find what it actually aggregates.
Am I doing something wrong?.
All the help is welcome. Thanks.Hi UzielB,
Based on your information, I get your requirement completely, here you want to accumulate the value of month from
Jan to March whin one year, then return to Jan again whin another year. If I misunderstand you please do not hesitate to let me know.
Now the issue you are encountering is that the value does not reset through the different years.
Actually, nomatter it is 2009 or 2010, RunningValue function takes different years as the same scope, so the value does not reset
through the different years. Just like picture3.
To workaround the issue, we might need to utilize the subreport in the main report, for detailed steps please follow
these:
1.
Design the subreport with two column groups
Year, Month and one row group Product.
2.
Type in the expression in the data textbox
=RunningValue(Fields!Yourdatafield.Value,sum,"Product") Here
Product is the row group name.
3.
Add one parameter
Year to the subreport, of course you should add the parameter year behind the where clause in the T-sql. Such as
select * from yourtable where Year=@Year
4.
Delete the
Year column and Product column, here please make sure you just delete the column only rather than deleting the relevant reportitem.
5.
Decrease the height and width of the report to the report control size, then there is no blank space when displayed in the main report.
6.
Drag a matrix to the main report, just add one column group
Year.
7.
Then drag a subreport control into the data textbox, and then rigth-click the subreport control->select subreport
properties
8.
In the Subreport Properties dialogbox, please selec the subreport name in the drop-down list of
Use this report as a subreport
9.
Swith to
Parameter tab, click Add button to add a parameter, then select the
Year in the Name drop-down list and
Year datafield in the Value drop-down list.
10.
Click OK.
11.
Now add another table control into the
main report body with one column, and drag the product datafiled into the data textbox. Then group the table by
Product.
12.
Drag this table into the
Rows textbox of the main report. Here make sure the height of the rows in Subreport and table creted in step11 is the same, otherwise the lines in not stay in the same level.
Preview the report, you will see the report like picture2.
If you have any question about the steps, please feel free to ask.
Have a wonderful day
J
Challen Fu -
Print Row Numbers and Column Letters
How do you tell Numbers to print the Row numbers and Column letters? This was very simple in Appleworks (print dialog box had that option). Can't find it in Numbers though.
Here is a script doing all the job for us.
Just select one or several cells in a table and run the script.
It duplicates it, add an header row, an header column, insert the needed labels and fill the other cells with a formula grabbing the contents of the original table.
--[SCRIPT build a table with headers]
Enregistrer len tant que Script: build a table with headers.scpt
déplacer le fichier 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.
Selectionner une cellule dans la table à dupliquer
menu Scripts > Numbers > build a table with headers
Le script duplique la table et crée des en-têtes de lignes et colonnes.
--=====
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 Script: build a table with headers.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 range of cells in the table to 'duplicate'
menu Scripts > Numbers > build a table with headers
The script duplicate the table and inserts columns/rows headers.
--=====
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)
2009/09/19
--=====
property theApp : "Numbers"
--=====
my activateGUIscripting() (* to be sure than GUI scripting will be active *)
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 new_Table to t_Name & "_#"
my duplicateTable(s_Name, t_Name, new_Table)
set delim to my getLocalizedDelimiter()
(* grab localized function names and add an open parenthesis at end *)
set IF_loc to my getLocalizedFunctionName("Numbers", "IF") & "("
set CHAR_loc to my getLocalizedFunctionName("Numbers", "CHAR") & "("
set INT_loc to my getLocalizedFunctionName("Numbers", "INT") & "("
set MOD_loc to my getLocalizedFunctionName("Numbers", "MOD") & "("
set INDIRECT_loc to my getLocalizedFunctionName("Numbers", "INDIRECT") & "("
set ADDRESS_loc to my getLocalizedFunctionName("Numbers", "ADDRESS") & "("
(* grab localized function names and add a couple of parenthesis at end *)
set ROW_loc to my getLocalizedFunctionName("Numbers", "ROW") & "()"
set COLUMN_loc to my getLocalizedFunctionName("Numbers", "COLUMN") & "()"
tell application "Numbers" to tell document d_Name to tell sheet s_Name to tell table new_Table
if column count = 256 then
if my parleAnglais() then
error "Oops, already 256 columns !"
else
error "Désolé, il y a déjà 256 colonnes !"
end if
end if
if row count = 65536 then
if my parleAnglais() then
error "Oops, already 65536 rows !"
else
error "Désolé, il y a déjà 65536 lignes !"
end if
end if
try
add row above row 1
on error
if my parleAnglais() then
error "Oops, already five header row !"
else
error "Désolé, il y a déjà cinq rangs d’en tête !"
end if
end try
try
add column before column 1
on error
if my parleAnglais() then
error "Oops, already five header columns !"
else
error "Désolé, il y a déjà cinq rangs d’en tête !"
end if
end try
set nbr to row count
set nbc to column count
(* =IF(COLUMN()<28,CHAR(COLUMN()63),CHAR(INT((COLUMN()-2)/26)+64)&CHAR(MOD(COLUMN()-2,26)65)) *)
set theFormula to "=" & IF_loc & COLUMN_loc & "<28" & delim & CHAR_loc & COLUMN_loc & "+63)" & delim & CHAR_loc & INT_loc & "(" & COLUMN_loc & "-2)/26)+64)&" & CHAR_loc & MOD_loc & COLUMN_loc & "-2" & delim & "26)+65))"
tell row 1
repeat with c from 2 to nbc
set value of cell c to theFormula
end repeat
end tell -- row 1
(* =ROW()-1 *)
set theFormula to "=" & ROW_loc & "-1"
tell column 1
repeat with r from 2 to nbr
set value of cell r to theFormula
end repeat
end tell -- column 1
(* =INDIRECT(ADDRESS(ROW()-1,COLUMN()-1,,,"Tableau 2")) *)
set theFormula to "=" & INDIRECT_loc & ADDRESS_loc & ROW_loc & "-1" & delim & COLUMN_loc & "-1" & delim & delim & delim & quote & t_Name & quote & "))"
repeat with r from 2 to nbr
repeat with c from 2 to nbc
set value of cell r of column c to theFormula
end repeat -- with c
end repeat -- with r
end tell -- Numbers
--=====
Set the parameter delimiter which must be used in Numbers formulas
on getLocalizedDelimiter()
if character 2 of (0.5 as text) is "." then
return ","
else
return ";"
end if
end getLocalizedDelimiter
--=====
on getLocalizedFunctionName(theApp, x)
local p2bndl
set p2bndl to (path to application support as text) & "iWork '09:Frameworks:SFTabular.framework:Versions:A:Resources:"
return my getLocalizedName(theApp, x, p2bndl)
end getLocalizedFunctionName
--=====
on getLocalizedName(a, x, f)
tell application a to return localized string x from table "Localizable" in bundle file f
end getLocalizedName
--=====
on getSelection()
local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
tell application "Numbers" to tell document 1
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 isItAsheet(s)
try
tell application "Numbers" to tell document 1
count of tables of sheet s (*
Post an error if s is not a sheet *)
end tell
return true
on error
return false
end try
end isItAsheet
--=====
on activateGUIscripting()
tell application "System Events"
if not (UI elements enabled) then set (UI elements enabled) to true (* to be sure than GUI scripting will be active *)
end tell
end activateGUIscripting
--=====
on duplicateTable(sourceSheet, sourceTable, newName)
local lesFeuilles, lesTables1, found, listOfRows, cor, i, isSourceSheet, nameI, j, lesTables2
tell application "Numbers"
activate
tell document 1
set lesFeuilles to name of sheets
if sourceSheet is in lesFeuilles then
tell sheet sourceSheet to set lesTables1 to name of tables
if sourceTable is not in lesTables1 then
if my parleAnglais() then
error "The sheet “" & sourceTable & "” of sheet “" & sourceSheet & "” is unavailable ! "
else
error "La table “" & sourceTable & "” de la feuille “" & sourceSheet & "” n'existe pas ! "
end if
end if -- sourceTable is not
else
if my parleAnglais() then
error "The sheet “" & sourceSheet & "” is unavailable ! "
else
error "La feuille “" & sourceSheet & "” n'existe pas ! "
end if
end if -- sourceSheet is in
end tell -- document
end tell -- application
if newName is not in lesTables1 then (*
Now, an ugly workaround to duplicate the sheet *)
set isOS4 to (system attribute "sys2") < 5
tell application "System Events" to tell application process "Numbers"
set docWindow to false (* CAUTION, an inspector ("AXFloatingWindow") or a Find/Search ("AXDialog") window may be open *)
repeat with i from 1 to (count of windows)
if subrole of window i is "AXStandardWindow" then
set docWindow to i (* got the document's window *)
exit repeat
end if
end repeat
if docWindow is not false then
tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window docWindow
select row 1
set value of attribute "AXFocused" to true
set found to false
set listOfRows to name of static text of every row
set cor to count of rows (* equal count of listOfRows *)
if isOS4 then (*
for mac Os X 10.4.11
CAUTION, listOfRows it's a list of lists !
{{"Feuille 2"}, {"Tableau 1"}, {"theSheet"}, {"Feuille 1"}, {"Tableau 2"}, {"Clément"}, {"Feuille 4"}} *)
repeat with i from 1 to cor (*
Scan the thumbnails *)
set nameI to item 1 of item i of listOfRows
set isSourceSheet to (sourceSheet = nameI) and my isItAsheet(nameI)
if isSourceSheet then
select row i
if (i < cor) and not my isItAsheet(item 1 of item (i + 1) of listOfRows) then (*
Here we may scan the thumbnails of tables of sourceSheet *)
repeat with j from i + 1 to i + (count of lesTables1)
if sourceTable = item 1 of item j of listOfRows then
select row j
set found to true
exit repeat
end if -- sourceTable
end repeat
else
if my parleAnglais() then
error "The sheet “" & sourceTable & "” of sheet “" & sourceSheet & "”" & return & " is not revealed in thumbnails ! "
else
error "La table “" & sourceTable & "” de la feuille “" & sourceSheet & "”" & return & " n'est pas affichée dans les vignettes ! "
end if -- my parleFrancais
end if -- (i < cor)
end if -- isSourceSheet
if found then exit repeat
end repeat -- i
else (*
for mac Os X 10.5.x
CAUTION, listOfRows is a list of lists !
{{}, {"Tableau 1"}, {"theSheet"}, {}, {"Tableau 2"}, {"Clément"}, {}}
With 10.5.x, the names of sheets are empty *)
repeat with i from 1 to cor
set isSourceSheet to (class of UI element 1 of row i is group) and (get value of static text 1 of group 1 of row i) is sourceSheet
if isSourceSheet then (*
Here we may scan the thumbnails of tables of sourceSheet *)
if value of UI element 1 of group 1 of row i is 0 then (*
reveal the tables's thumbnails and adjust the list accordingly *)
click UI element 1 of group 1 of row i (* click the black triangle to reveal tables *)
delay 0.1
set listOfRows to name of static text of every row (* update the list accordingly *)
end if -- value of UI…
repeat with j from i + 1 to i + (count of lesTables1)
if sourceTable = item 1 of item j of listOfRows then
select row j
set found to true
exit repeat
end if -- sourcetable
end repeat -- with j
end if -- isSourceSheet
if found then exit repeat
end repeat -- with i
end if -- check OS
end tell -- outline …
keystroke "d" using command down
end if -- docWindow
end tell -- System Events…
if docWindow is not false then (*
Rename the new table according to the passed name: newTable *)
tell application "Numbers" to tell document 1 to tell sheet sourceSheet
set lesTables2 to name of tables
repeat with i in lesTables2
if i is not in lesTables1 then (*
Here i is the name of the newly created table *)
set name of table i to newName
exit repeat
end if
end repeat
end tell
end if -- docWindow
end if -- newName is not…
end duplicateTable
--=====
on parleAnglais()
local z
try
tell application theApp to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) samedi 19 septembre 2009 17:33:59 -
Display rows into multiple columns
I have a table in the following format:
id value
a1 0
a2 0
a3 0
a4 0
b1 0
b2 0
b3 0
b4 0
how do I go about displaying it into four columns in the following format:
id1 value1 id2 value2
a1 0 b1 0
a2 0 b2 0
a3 0 b3 0
a4 0 b4 0Hi,
789063 wrote:
I got that error in toad. So now I am testing from command prompt. When you say "command prompt", do you mean SQL*Plus?
Sorry, I don't know much about Toad. If Toad is returning 0 rows, and the same query is returning 8 rows in SQL*Plus, then I suspect you are not connecting to the same database or the same user. ASre you sure you're running the exact same query in both front ends?
Here is the data set that I am testing for:
<pre>
id1 value
smple_val_1 0
smple_val_2 1
smple_val_3 1
smple_val_4 2
smple_other_1 3
smple_other_2 5
smple_other_3 8
smple_other_4 13
some_other_val1 1
some_other_val2 0
some_other_val3 3
some_other_val4 5
</pre>
I am trying to select only 'smple%' in the query, which should display in four columns like:
<pre>
id1 val1 id2 val2
smple_val_1 1 smple_other_1 3
smple_val_2 0 smple_other_2 5
smple_val_3 0 smple_other_3 8
smple_val_4 2 smple_other_4 13
</pre>Is that really the output you want? Why not
ID1 VAL1 ID2 VAL2
smple_val_1 0 smple_other_1 3
smple_val_2 1 smple_other_2 5
smple_val_3 1 smple_other_3 8
smple_val_4 2 smple_other_4 13with the 0's and 1's in the val1 column reversed?
Here is the ddl I used:
<pre>
CREATE TABLE table_x
( id VARCHAR2 (20) PRIMARY KEY
, value NUMBER
INSERT INTO table_x (id, value) VALUES ('smple_val_1', 0);
INSERT INTO table_x (id, value) VALUES ('smple_val_2', 1);
INSERT INTO table_x (id, value) VALUES ('smple_val_3', 1);
INSERT INTO table_x (id, value) VALUES ('smple_val_4', 2);
INSERT INTO table_x (id, value) VALUES ('smple_other_1', 3);
INSERT INTO table_x (id, value) VALUES ('smple_other_2', 5);
INSERT INTO table_x (id, value) VALUES ('smple_other_3', 8);
INSERT INTO table_x (id, value) VALUES ('smple_other_4', 13);
INSERT INTO table_x (id, value) VALUES ('some_other_val1', 1);
INSERT INTO table_x (id, value) VALUES ('some_other_val2', 0);
INSERT INTO table_x (id, value) VALUES ('some_other_val3', 3);
INSERT INTO table_x (id, value) VALUES ('some_other_val4', 5);
</pre>Thanks, that's good.
Where is the explanation of how you get the results you want from that data? There are a lot of different ways to get the same results from the same data, especially from a small set of sample data. I might provide a query that gets the right results for the wrong reasons, and when you run that query on a different set of data, it won't necessarily work. That's exactly what happened before. I guessed at what you wanted, but I guessed wrong. Guessing is not a very efficient or reliable way to solve problems. Don't make people guess: explain what you want.
In particular, explain how you can tell, buy looking at a row and column in the original table, to which row and which column of the output it corresponds. I'm pretty sure that the id column of the table always corresponds to either the id1 or idl2 column of the output, and that value always corresponds to either val1 or val2. From this latest set of sample data, it looks like all the rows in table_x that start with 'smple_val' will correspond to the id1 and val1 columns, and that all therows that start with 'smple_other_' will correspond to the id2 and val2 columns. It also looks like each row of the output represents a unique value of the last character of table_x.id.
If I guessed right this time, then what you want is:
SELECT MIN (CASE WHEN id LIKE 'smple\_val\_%' ESCAPE '\' THEN id END) AS id1
, MIN (CASE WHEN id LIKE 'smple\_val\_%' ESCAPE '\' THEN value END) AS val1
, MIN (CASE WHEN id LIKE 'smple\_other\_%' ESCAPE '\' THEN id END) AS id2
, MIN (CASE WHEN id LIKE 'smple\_other\_%' ESCAPE '\' THEN value END) AS val2
FROM table_x
GROUP BY SUBSTR (id, -1)
ORDER BY SUBSTR (id, -1)
;But this is only a guess. I can't guarrantee that this will work on your real data any better than my last guess did. You'll get better answers faster if you provide an explanation, so that poeple don't have to guess so much. -
Inserting a db row from a form with a value passed in from another page
We have a report (P1) on a table (T1). P1 has a link column (C), and C is the PK on T1. Clicking on a link (i.e., a row) in report P1, takes us to form (P2). P2 is used to allow the user to insert a new row into T1, with the constraint that one of the columns (X) in T1 must have the same value as X had in the linked row on P1. Also, X is a NOT NULL attribute.
What we are doing is:
First, passing C to P2 by setting the link name=P2_X_C and the link value=#C#
Second, in P2, we are setting form element P2_C via a SQL statement:
SELECT X
FROM T1
WHERE C = :P2_X_C
P2 displays nicely. We set P2_C to display only, and allow the user to enter values for the other columns. The value displayed for X is not NULL and correctly matches the value from P1. However, when we hit the CREATE button on P2, we get error: ORA-01400: cannot insert NULL into "T1"."X". Unable to process row of table T1.
APEX seems to have an "issue" with having a value in a form "set" and transmitted to the DB on INSERT.
Any help would be greatly appreciated.Hi,
1 For "Display Only" items that you are not populating directly from a database column, if you want to save the value, you have to ensure that Save Session State is set to Yes and these items are not actually submitted with the page. The same sort of thing would apply to Disabled or Read-Only items as browsers do not submit these items - though these are more tricky to deal.
2 Passing the PK value is the most common way of identifying which record contains the values you need. Passing other values is also typical - eg, for applying filters for calendars or searches or for setting flags.
3 For database columns, which should be based on the underlying table's data, you can use the Default Value settings - though be aware that these values do not exist in session state until the page is submitted. That's ok if you don't need to use the value anywhere else on your page
Andy -
Inserting 10 million rows in to a table hangs
HI through toad iam using a simple for loop to insert 10 million rows into a table by saying
for i in 1 ......10000000
insert.................
It hangs ........ for lot of time
is there a better way to insert the rows in to the table....?
i have to test for performance.... and i have to insert 50 million rows in its child table..
practically when the code moves to production it will have these many rows...(may be more also) thats why i have to test for these many rows
plz suggest a better way for this
Regards
rajMust be a 'hardware thing'.
My ancient desktop (pentium IV, 1.8 Ghz, 512 MB), running XE, needs:
MHO%xe> desc t
Naam Null? Type
N NUMBER
A VARCHAR2(10)
B VARCHAR2(10)
MHO%xe> insert /*+ APPEND */ into t
2 with my_data as (
3 select level n, 'abc' a, 'def' b from dual
4 connect by level <= 10000000
5 )
6 select * from my_data;
10000000 rijen zijn aangemaakt.
Verstreken: 00:04:09.71
MHO%xe> drop table t;
Tabel is verwijderd.
Verstreken: 00:00:31.50
MHO%xe> create table t (n number, a varchar2(10), b varchar2(10));
Tabel is aangemaakt.
Verstreken: 00:00:01.04
MHO%xe> insert into t
2 with my_data as (
3 select level n, 'abc' a, 'def' b from dual
4 connect by level <= 10000000
5 )
6 select * from my_data;
10000000 rijen zijn aangemaakt.
Verstreken: 00:02:44.12
MHO%xe> drop table t;
Tabel is verwijderd.
Verstreken: 00:00:09.46
MHO%xe> create table t (n number, a varchar2(10), b varchar2(10));
Tabel is aangemaakt.
Verstreken: 00:00:00.15
MHO%xe> insert /*+ APPEND */ into t
2 with my_data as (
3 select level n, 'abc' a, 'def' b from dual
4 connect by level <= 10000000
5 )
6 select * from my_data;
10000000 rijen zijn aangemaakt.
Verstreken: 00:01:03.89
MHO%xe> drop table t;
Tabel is verwijderd.
Verstreken: 00:00:27.17
MHO%xe> create table t (n number, a varchar2(10), b varchar2(10));
Tabel is aangemaakt.
Verstreken: 00:00:01.15
MHO%xe> insert into t
2 with my_data as (
3 select level n, 'abc' a, 'def' b from dual
4 connect by level <= 10000000
5 )
6 select * from my_data;
10000000 rijen zijn aangemaakt.
Verstreken: 00:01:56.10Yea, 'cached' it a bit (ofcourse ;) )
But the append hint seems to knibble about 50 sec off anyway (using NO indexes at all) on my 'configuration'. -
Different number of rows for different columns in JTable
hi
I need to create a JTable with different number of rows for different columns...
Also the rowheight should be different in each column...
say there is a JTable with 2 columns... Col1 having 5 rows and column 2 having 2 rows...
The rowHeight in Col2 should be an integer multiple of Rowheight in Col1
how do I do this ??
can anybody send me some sample code ?????
thanx in advanceHow about nesting JTables with 1 row and many columns in a JTable with 1 column and many rows.
Or you could leave the extra columns null/blank.
You could use a GridBagLayout and put a panel in each group of cells and not use JTable at all.
It would help if you were more specific about how you wanted it to appear and behave. -
SSRS 2008 R2 - Add moving average to column group
I have a column group of dollar amounts. The row is a year/month. I would like to add a moving average column to the right of the last 6 months. My SQL Server data source is already complex enough and I'd really prefer not to add a column
there. Is there anything I can do within the report itself? Some way to reference the previous records in a matrix?
Thank you!Hi mateoc15,
According to your description, you have a matrix in your report. Now you want to calculate the average value of last 6 month. Right?
In Reporting Service, we can put custom code into report to deal with complicated logic. Add one more column/row inside of group and call the functions defined in custom code. For your requirement we modified Robert’s code to achieve your goal. We tested
your case in our local environment with sample data. Here are steps and screenshots for your reference:
Put the custom code into report:
Private queueLength As Integer = 6
Private queueSum As Double = 0
Private queueFull As Boolean = False
Private idChange As String=""
Dim queue As New System.Collections.Generic.Queue(Of Integer)
Public Function CumulativeQueue(ByVal currentValue As Integer,id As String) As Object
Dim removedValue As Double = 0
If idChange <> id then
ClearQueue()
idChange = id
queueSum = 0
queueFull = False
CumulativeQueue(currentValue,id)
Else
If queue.Count >= queueLength Then
removedValue = queue.Dequeue()
End If
queueSum += currentValue
queueSum -= removedValue
queue.Enqueue(currentValue)
If queue.Count < queueLength Then
Return Nothing
ElseIf queue.Count = queueLength And queueFull = False Then
queueFull = True
Return queueSum / queueLength
Else
Return (queueSum) / queueLength
End If
End If
End Function
public function ClearQueue()
Dim i as Integer
Dim n as Integer = Queue.Count-1
for i=n To 0 Step-1
queue.Dequeue()
next i
End function
Add one more row inside of group, call the function defined in custom code.
Save and preview. It looks like below:
Reference:
Moving or rolling average, how to?
If you have any question, please feel free to ask.
Best Regards,
Simon Hou (Pactera)
Maybe you are looking for
-
Hello, I am having a hard time finding a process for burning 23.98 footage onto a DVD without having the method of 3:2 pulldown effecting the overall look. I have a sequence in Final Cut Pro that is 23.98. I'd like to burn it to a DVD but when the 3:
-
Unable to send or recieve images via drag and drop?
I am unable to send or recieve jpg and gif images by dragging and dropping from finder. How do I fix this?
-
Size of .mov and encoding time
Hey. Does anyone know the appoximate size of a 40 min .mov movie and after imported in DVS Studio Pro 2- how long does it take to encode it? Minutes? Hours? Days? Thanks!
-
Webutil errors WUO-714 and 705
I am getting following errors when I try to call a third party application using webutil. It is working fine but apparently in the java console I see these errors . Same code works great in 6 and 6i. I am basically creating an object and logging into
-
Adobe Illustrator CS5 saves two page PDF
When I open older version AI file in CS5 and then resave in PDF it creates a multi-page PDF. Why? It seems like it keeps the older version. How do discard multipage when saving PDF in Illustrator?