How to calculate cumulative percentages?
i have a query to get month to date data
select site,pmonth,sum(a)/sum(b)*100 as MTD
from
mytable
group by site,pmonth
Need help calculating year to date percentage..
Hi Solomon,
Thanks for your solution but as I'm working on percentages, it needs to be cumulative percentages.
if i have sample data like:
site month mtd ytd
site1 1-jan-2011 20% 20%
site1 1-feb-2011 30% 50%
site1 1-mar-2011 50% 100%
something like this..
Similar Messages
-
How to calculate milestone percentage for final milestone (billing rule 3)
Hi,
Client is using percentage based milestone billing. For final milestone, billing rule is set to "3 Closing invoice in milestone billing" and milestone percentage, field FPROZ, is empty without any value.
My aim is to calculate final milestone percentage, so it would be printed on invoice layout.
I have suggested below logic to developer:
"If RV60F-SFPRO field is not equal to 0,00 (zero), pass billing plan VBRP-FPLNR and item numbers VBRP-FPLTR into FPLT table to get FPLT-FPROZ"
But developer can't find RV60F-SFPRO value anyway...
Therefore, I have a problem - how to calculate final milestone percentage in this case?
Could anyone provide any other logic how to calculate it?Percentage can't be added into final milestone in SO billing plan, field FPROZ is not editable....
Moreover, this milestone just have billing value in SO billing plan.
I am going to use this logic that hopefully would fix the issue:
If invoice billing type VBRP-FKART value is XXX and billing plan rule FAREG value is 1, or 3, or 4, or 5, then milestone percentage should be calculated by following formula: milestone billing value x 100 and then divided by order net value from VBAP-NETWR.
If invoice billing type XXX, but billing plan rule is different then, no milestone percentage is not printed. This logic is valid for header and item level billing. -
How to calculate Sales percentage difference between selected year and its previous year in a Matrix
Hi,
I'm trying to generate a report using matrix like this
Month
Product PreviousYearSalesAmount SelectedYearSalesAmount %SalesDifference
I can populate year sales amount, but i cant calculate the percentage.
Can Anyone help me please.
Note: Month and Year are passed as parameters.
Thank you.Hi Abhiram,
As per my understanding you can show your fields in matrix.
Only problem is to create the additional column which will have the %SalesDifference value right?
If yes,
Just create one column as shown in below screen,
It will create one column, Name the header of this newly created column as %SalesDifference
In below this header , where you want to show the value for %SalesDifference as
=sum(iif(Fields!year.Value=Parameters!year.Value,(Fields!SalesAmount.Value),-Fields!SalesAmount.Value))/Fields!SalesAmount.Value
Set the property of the column in number as Percentage.
run the report, you will see as below screen.
For your reference I am attaching my RDL code, you can save as .rdl file and run the report (sample Data inside the report only)
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<Body>
<ReportItems>
<Textbox Name="textbox1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Matrix</Value>
<Style>
<FontFamily>Tahoma</FontFamily>
<FontSize>14pt</FontSize>
<FontWeight>Bold</FontWeight>
<Color>SteelBlue</Color>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>textbox1</rd:DefaultName>
<Height>0.37in</Height>
<Width>5in</Width>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Tablix Name="Tablix1">
<TablixCorner>
<TablixCornerRows>
<TablixCornerRow>
<TablixCornerCell>
<CellContents>
<Textbox Name="Textbox16">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Product</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox16</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>LightBlue</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCornerCell>
</TablixCornerRow>
<TablixCornerRow>
<TablixCornerCell>
<CellContents>
<Textbox Name="Textbox17">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox17</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCornerCell>
</TablixCornerRow>
</TablixCornerRows>
</TablixCorner>
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>1.79722in</Width>
</TablixColumn>
<TablixColumn>
<Width>1.76722in</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="SalesAmount">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Sum(Fields!SalesAmount.Value)</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>SalesAmount</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox76">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=sum(iif(Fields!year.Value=Parameters!year.Value,(Fields!SalesAmount.Value),-Fields!SalesAmount.Value))/Fields!SalesAmount.Value</Value>
<Style>
<Format>0.00%</Format>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox76</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
</TablixRows>
</TablixBody>
<TablixColumnHierarchy>
<TablixMembers>
<TablixMember>
<Group Name="month">
<GroupExpressions>
<GroupExpression>=Fields!month.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!month.Value</Value>
</SortExpression>
</SortExpressions>
<TablixHeader>
<Size>0.25in</Size>
<CellContents>
<Textbox Name="month1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=MonthName(Fields!month.Value)</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>month1</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>LightBlue</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember>
<Group Name="year">
<GroupExpressions>
<GroupExpression>=Fields!year.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!year.Value</Value>
</SortExpression>
</SortExpressions>
<TablixHeader>
<Size>0.25in</Size>
<CellContents>
<Textbox Name="year">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!year.Value</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>year</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember />
</TablixMembers>
</TablixMember>
</TablixMembers>
</TablixMember>
<TablixMember>
<TablixHeader>
<Size>0.25in</Size>
<CellContents>
<Textbox Name="Textbox61">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>%SalesDifference</Value>
<Style>
<FontStyle>Normal</FontStyle>
<FontWeight>Bold</FontWeight>
<TextDecoration>None</TextDecoration>
<Color>#000000</Color>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox61</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>LightBlue</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember>
<TablixHeader>
<Size>0.25in</Size>
<CellContents>
<Textbox Name="Textbox62">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox62</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
</TablixMember>
</TablixMembers>
</TablixMember>
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<Group Name="Product">
<GroupExpressions>
<GroupExpression>=Fields!Product.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!Product.Value</Value>
</SortExpression>
</SortExpressions>
<TablixHeader>
<Size>1.38889in</Size>
<CellContents>
<Textbox Name="Product1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Product.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Product1</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSet1</DataSetName>
<Top>0.38in</Top>
<Left>0.04667in</Left>
<Height>0.75in</Height>
<Width>4.95333in</Width>
<ZIndex>1</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
</Style>
</Tablix>
</ReportItems>
<Height>1.20167in</Height>
<Style />
</Body>
<Width>5.1in</Width>
<Page>
<LeftMargin>1in</LeftMargin>
<RightMargin>1in</RightMargin>
<TopMargin>1in</TopMargin>
<BottomMargin>1in</BottomMargin>
<Style />
</Page>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="DataSource1">
<DataSourceReference>DataSource1</DataSourceReference>
<rd:SecurityType>None</rd:SecurityType>
<rd:DataSourceID>501ee6de-61fb-416f-9a92-011661d01cba</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<DataSourceName>DataSource1</DataSourceName>
<QueryParameters>
<QueryParameter Name="@year">
<Value>=Parameters!year.Value</Value>
</QueryParameter>
<QueryParameter Name="@Month">
<Value>=Parameters!Month.Value</Value>
</QueryParameter>
</QueryParameters>
<CommandText>select * from
select 'apple' Product ,1 month ,2014 year,2000 SalesAmount
union
select 'apple' Product ,1 month,2015 year,3000 SalesAmount
union
select 'dell' Product ,1 month,2014 year,3000 SalesAmount
union
select 'dell' Product ,1 month,2015 year,2500 SalesAmount
union
select 'apple' Product ,2 month,2014 year,1500 SalesAmount
union
select 'apple' Product ,2 month,2015 year,3000 SalesAmount
union
select 'dell' Product ,2 month,2014 year,3000 SalesAmount
union
select 'dell' Product ,2 month,2015 year,5500 SalesAmount
)t
where year between @year-1 and @year
and Month=@Month</CommandText>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
</Query>
<Fields>
<Field Name="Product">
<DataField>Product</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="month">
<DataField>month</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="year">
<DataField>year</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="SalesAmount">
<DataField>SalesAmount</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<ReportParameters>
<ReportParameter Name="year">
<DataType>String</DataType>
<DefaultValue>
<Values>
<Value>2015</Value>
</Values>
</DefaultValue>
<Prompt>year</Prompt>
</ReportParameter>
<ReportParameter Name="Month">
<DataType>String</DataType>
<DefaultValue>
<Values>
<Value>1</Value>
</Values>
</DefaultValue>
<Prompt>Month</Prompt>
</ReportParameter>
</ReportParameters>
<Language>en-US</Language>
<ConsumeContainerWhitespace>true</ConsumeContainerWhitespace>
<rd:ReportUnitType>Inch</rd:ReportUnitType>
<rd:ReportID>ee1a8383-6595-42b1-94f2-c68d681c85d3</rd:ReportID>
</Report>
Thanks
Prasad
Mark this as Answer if it helps you to proceed on further. -
How to calculate the percentage of free space for a table in Oracle
okay, I am a little confused here. I have been searching the web and looking at a lot of documents. What I basically want to find out is this, how do I calculate the difference between the number of bytes a table is using and the total bytes allocated to a table space (going that way to get percent free for a particular table). So I need a byte count of a table and total table space and the percentage difference. I have been looking at the DBA_TABLES DBA_TABLESPACES and DBA_SEGMENTS views. I have tried to calculated the space as num_rows * avg_row_len (if I am wrong, let me know). I have been trying to compare that calculation to the number in DBA_TABLESPACES and DBA_SEGMENTS. I am just looking for the total space allocated to the table space that the table sits in (seem logical right now) to make the percentage value work. Thus I want to be able to track the table as it grows as compated to the table space it sits in to see a value as it changes over time (days, weeks, etc.) each time I run this script I am working on.
Can someone get me straight and help me to find out if I am looking in the right places. Any advice would help.
EdwardYou can use a little modified version of dbms_space from Tom, show_space. Have a look,
SQL> create table test222 as select * from all_objects;
Table created.
SQL> delete from test22 where rownum<=100;
delete from test22 where rownum<=100
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> delete from test222 where rownum<=100;
100 rows deleted.
SQL> analyze table test222 compute statistics;
Table analyzed.
SQL> create or replace procedure show_space
2 ( p_segname in varchar2,
3 p_owner in varchar2 default user,
4 p_type in varchar2 default 'TABLE',
5 p_partition in varchar2 default NULL )
6 -- this procedure uses authid current user so it can query DBA_*
7 -- views using privileges from a ROLE and so it can be installed
8 -- once per database, instead of once per user that wanted to use it
9 authid current_user
10 as
11 l_free_blks number;
12 l_total_blocks number;
13 l_total_bytes number;
14 l_unused_blocks number;
15 l_unused_bytes number;
16 l_LastUsedExtFileId number;
17 l_LastUsedExtBlockId number;
18 l_LAST_USED_BLOCK number;
19 l_segment_space_mgmt varchar2(255);
20 l_unformatted_blocks number;
21 l_unformatted_bytes number;
22 l_fs1_blocks number; l_fs1_bytes number;
23 l_fs2_blocks number; l_fs2_bytes number;
24 l_fs3_blocks number; l_fs3_bytes number;
25 l_fs4_blocks number; l_fs4_bytes number;
26 l_full_blocks number; l_full_bytes number;
27
28 -- inline procedure to print out numbers nicely formatted
29 -- with a simple label
30 procedure p( p_label in varchar2, p_num in number )
31 is
32 begin
33 dbms_output.put_line( rpad(p_label,40,'.') ||
34 to_char(p_num,'999,999,999,999') );
35 end;
36 begin
37 -- this query is executed dynamically in order to allow this procedure
38 -- to be created by a user who has access to DBA_SEGMENTS/TABLESPACES
39 -- via a role as is customary.
40 -- NOTE: at runtime, the invoker MUST have access to these two
41 -- views!
42 -- this query determines if the object is a ASSM object or not
43 begin
44 execute immediate
45 'select ts.segment_space_management
46 from dba_segments seg, dba_tablespaces ts
47 where seg.segment_name = :p_segname
48 and (:p_partition is null or
49 seg.partition_name = :p_partition)
50 and seg.owner = :p_owner
51 and seg.tablespace_name = ts.tablespace_name'
52 into l_segment_space_mgmt
53 using p_segname, p_partition, p_partition, p_owner;
54 exception
55 when too_many_rows then
56 dbms_output.put_line
57 ( 'This must be a partitioned table, use p_partition => ');
58 return;
59 end;
60
61
62 -- if the object is in an ASSM tablespace, we must use this API
63 -- call to get space information, else we use the FREE_BLOCKS
64 -- API for the user managed segments
65 if l_segment_space_mgmt = 'AUTO'
66 then
67 dbms_space.space_usage
68 ( p_owner, p_segname, p_type, l_unformatted_blocks,
69 l_unformatted_bytes, l_fs1_blocks, l_fs1_bytes,
70 l_fs2_blocks, l_fs2_bytes, l_fs3_blocks, l_fs3_bytes,
71 l_fs4_blocks, l_fs4_bytes, l_full_blocks, l_full_bytes, p_partition);
72
73 p( 'Unformatted Blocks ', l_unformatted_blocks );
74 p( 'FS1 Blocks (0-25) ', l_fs1_blocks );
75 p( 'FS2 Blocks (25-50) ', l_fs2_blocks );
76 p( 'FS3 Blocks (50-75) ', l_fs3_blocks );
77 p( 'FS4 Blocks (75-100)', l_fs4_blocks );
78 p( 'Full Blocks ', l_full_blocks );
79 else
80 dbms_space.free_blocks(
81 segment_owner => p_owner,
82 segment_name => p_segname,
83 segment_type => p_type,
84 freelist_group_id => 0,
85 free_blks => l_free_blks);
86
87 p( 'Free Blocks', l_free_blks );
88 end if;
89
90 -- and then the unused space API call to get the rest of the
91 -- information
92 dbms_space.unused_space
93 ( segment_owner => p_owner,
94 segment_name => p_segname,
95 segment_type => p_type,
96 partition_name => p_partition,
97 total_blocks => l_total_blocks,
98 total_bytes => l_total_bytes,
99 unused_blocks => l_unused_blocks,
100 unused_bytes => l_unused_bytes,
101 LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,
102 LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,
103 LAST_USED_BLOCK => l_LAST_USED_BLOCK );
104
105 p( 'Total Blocks', l_total_blocks );
106 p( 'Total Bytes', l_total_bytes );
107 p( 'Total MBytes', trunc(l_total_bytes/1024/1024) );
108 p( 'Unused Blocks', l_unused_blocks );
109 p( 'Unused Bytes', l_unused_bytes );
110 p( 'Last Used Ext FileId', l_LastUsedExtFileId );
111 p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );
112 p( 'Last Used Block', l_LAST_USED_BLOCK );
113 end;
114
115 /
Procedure created.
SQL> desc show_space
PROCEDURE show_space
Argument Name Type In/Out Default?
P_SEGNAME VARCHAR2 IN
P_OWNER VARCHAR2 IN DEFAULT
P_TYPE VARCHAR2 IN DEFAULT
P_PARTITION VARCHAR2 IN DEFAULT
SQL> set serveroutput on
SQL> exec show_space('TEST222','SCOTT');
BEGIN show_space('TEST222','SCOTT'); END;
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at "SCOTT.SHOW_SPACE", line 44
ORA-06512: at line 1
SQL> conn / as sysdba
Connected.
SQL> grant sysdba to scott;
Grant succeeded.
SQL> conn scott/tiger as sysdba
Connected.
SQL> exec show_space('TEST222','SCOTT');
BEGIN show_space('TEST222','SCOTT'); END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'SHOW_SPACE' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SQL> exec scott.show_space('TEST222','SCOTT');
PL/SQL procedure successfully completed.
SQL> set serveroutput on
SQL> exec scott.show_space('TEST222','SCOTT');
Unformatted Blocks ..................... 0
FS1 Blocks (0-25) ..................... 0
FS2 Blocks (25-50) ..................... 1
FS3 Blocks (50-75) ..................... 0
FS4 Blocks (75-100)..................... 1
Full Blocks ..................... 807
Total Blocks............................ 896
Total Bytes............................. 7,340,032
Total MBytes............................ 7
Unused Blocks........................... 65
Unused Bytes............................ 532,480
Last Used Ext FileId.................... 4
Last Used Ext BlockId................... 1,289
Last Used Block......................... 63
PL/SQL procedure successfully completed.
SQL>http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5350053031470
I use this to find the space allocations.
Just read your post again,this is not going to show you the percentage of the free/used space. This is going to be the number of blocks which are free/used. For the growth trend, you can look at (in 10g) Oracle EM. It has added now,Segment Growth Trend report which can show you for each object,comparing to the allocated space to the object,how much space is being used by it.
HTH
Aman.... -
How to calculate the Percentage differencebased on two values
Not sure how to do this.
Just want to calculate the % difference of two values (seem to have a problem when one value is zero)
Here is the current output
49 Apr 2
64 Aug 1
55 Feb 0
Here is the output I would like to see
49 Apr 2 4.08%
64 Aug 1 1.56%
55 Feb 0 0.00%
Here is the current SQL
Select TO_CHAR (RCA_CLOSE_DATE, 'Month') "Month",
SUM (CASE WHEN RCA_CODE = 'BI&D' THEN 1 ELSE 0 END) "BI&D - CBAT No of Adj",
Count(1) as "Count of Adjustments"
from TW_BILL_ADJ_DATA
where (RCA_CLOSE_DATE between nvl (:P8_DATE_FROM,FORM_RECEIVED)
and nvl (:P8_DATE_TO, FORM_RECEIVED))
group by TO_CHAR (RCA_CLOSE_DATE, 'Month')You can try something like this one:
Select TO_CHAR (RCA_CLOSE_DATE, 'Month') "Month",
SUM (CASE WHEN RCA_CODE = 'BI&D' THEN 1 ELSE 0 END) "BI&D - CBAT No of Adj",
Count(1) as "Count of Adjustments",
round(count(1)/SUM(CASE WHEN RCA_CODE = 'BI&D' THEN 1 ELSE 0 END) * 100,2) || '%' percent
from TW_BILL_ADJ_DATA
where (RCA_CLOSE_DATE between nvl (:P8_DATE_FROM,FORM_RECEIVED)
and nvl (:P8_DATE_TO, FORM_RECEIVED))
group by TO_CHAR (RCA_CLOSE_DATE, 'Month')
CODE NOT TESTED !!!
Best Regards
Krystian Zieja / mob -
How to calculate the percentages
Hi Gurus!!
I am having a key figure(say suppose KF1) which had undergone currency conversions in query designer level to USD.
Now i want one more field(KF2) in my report in which i should get the values of percentages based on KF1 and its overall result.
Means i have 1000,2500,3400....under KF1 and the total is 25000. Finally under KF2 i should get as mentioned below
KF1----
>KF2
1000----
>(1000/25000)*100
2500----
>(2500/25000)*100
3400----
>(3400/25000)*100
So like wise i shold get the percentages based on KF1 and its total.
I had tried SUMGT and %GT functions as mentioned below:
kf1/sumgt(kf1) and kf1/%GT(kf1) and for both of them the query is showing errors like you cannot use these functions in the query. correct the query.
Pls suggest me the solution.
Thanks in Advance
Jiten
Edited by: Jitendra Yuddandi on Jun 9, 2009 12:20 PMcheck these links
http://help.sap.com/saphelp_nw04s/helpdata/en/1e/99ea3bd7896f58e10000000a11402f/frameset.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/e2/16f13a2f160f28e10000000a114084/frameset.htm -
How to calculate a percentage in a Matrix row SSRS
HI All,
I have the following data in a SSRS Matrix. I want the data to reflect as 'B' but I constantly get data reflected as a total.(C)
I need the percentage per row and not the whole total value.
this is my expression =count(Fields!Rejection_Reason.Value)/sum(Fields!ClaimCount.Value, "DataSet1")
A
Dealer
Total Sold
VW
Mercrcedez
Honda
Dealer1
10
2
5
3
Dealer2
20
5
10
5
Dealer3
30
10
5
15
B
Dealer
Total Sold
VW
Mercedez
Honda
Dealer1
10
20.00%
50.00%
30.00%
Dealer2
20
25.00%
50.00%
25.00%
Dealer3
30
33.33%
16.67%
50.00%
C
Dealer
Total Sold
VW
Mercedez
Honda
Dealer1
10
3.33%
8.33%
5.00%
Dealer2
20
8.33%
16.67%
8.33%
Dealer3
30
16.67%
8.33%
25.00%
60
Thank you for your help.Hi Andrevw23,
Just as michlimes suggested, we should sum the value of ClaimCount field in the Dealer group region, other than the dataset. Because the sum function sum all non-null numeric values in the specified scope. So in your scenario, we can try to use the function
below to achieve your requirement (“Dealer” means the name of Dealer group):
=count(Fields!Rejection_Reason.Value)/sum(Fields!ClaimCount.Value, "Dealer")
If you have any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How to calculate a percentage of a Running Total?
Post Author: pvang
CA Forum: Formula
Hi folks, Quite new here to the forum and to Crystal Report. As you can tell, I've already stumbled upon a roadblock. Here is what I'm trying to do:I am grabbing employee names and the number of cases that they are working via a sql query. So the sql query will result in something like 'Bob', '403'; Bob being the employee and 403 being the number of cases he's working on. In the report, I have a running total that sums up the total number of cases. I want to determine the ratio of Bob's(and every other employee's) cases over the running total amount of cases. So, for demo purposes, Bob has 403 cases and the total amount of cases is 1612, Bob's ratio would be 25%(403/1612). The equation that I am using right now is: /{#RTotal})*100 and it is not working. The ratio starts at 100%(effectively because the running total after the first record is equal to his/her cases) and then drops off dramatically. I know why it is doing that, just don't want those results. I tried using the EvaluateAfter function to no avail. Is this possible? If so, how? Many thanks in advance.Post Author: rroberson
CA Forum: Formula
Sounds to me like you don't need to use a running total. Just group on name (bob) and do a normal total (not running total) for the group (group summary). You can just divide that group summary total by the grand total (another crystal summary) and mult by 100. -
How to calculate Cumulative of Daily for particular field(Actual Meter )
hi,
pls help me in this
thanksHi,
refer the link it may help you
https://forums.sdn.sap.com/click.jspa?searchID=4388506&messageID=3350823
https://forums.sdn.sap.com/click.jspa?searchID=4388506&messageID=3889681
Regards -
How to calculate percentage of errors in DP
Hi Gurus,
Can anyone tell me How to calculate the percentage of errors?
I had generated forecast and wanted to know how much is the error we have .
Please let me know your answers
Thanks a Lot
regards,
RajHi Gurus,
I just wanted to know how to get lowest percentage errors for my forecast and make business happy ?
I am using "Auto Model selection-2" and i wanted to have lowest percentage errors and what should i do for it?
What alpha , Beta and Gamma values need to keep in forecast profile?
Please let me know it will be really great
Thanks for the answers
Regards,
raj -
How to calculate total for field for particular day. in smart forms
hi,
pls help in this problem,
how to calculate cumulative totals for the particular field in samrtformsHi ,
Either you can calculate the sum in driver program with
Loop at where Condition .
Sum the required field .
endloop .
Then pass it to smartforms
Or
Double Click on table node .
In the conditions tab give the required condition .
select calculation tab.
In operation select Total , in field name give the name of the field you want to sum
and in targer field name specify the name of the field that should contain the result .
To convert the total in to words use the function module in program lines
CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
amt_in_num = w_total
IMPORTING
AMT_IN_WORDS = w_total_words
EXCEPTIONS
DATA_TYPE_MISMATCH = 1
OTHERS = 2
Regards -
How to calculate statistics stale %
Hi All,
i have configured automatic statistics gathering job in my database(11.2.0.4) to calculate object statistics with stale % a>= 10. I am having a doubt how Oracle calculates stale percentage of an object. I did search in OTN discussion and found the below querry
SELECT DT.OWNER,
DT.TABLE_NAME,
ROUND ( (DELETES + UPDATES + INSERTS) / NUM_ROWS * 100) PERCENTAGE
FROM DBA_TABLES DT, DBA_TAB_MODIFICATIONS DTM
WHERE DT.OWNER = DTM.TABLE_OWNER
AND DT.TABLE_NAME = DTM.TABLE_NAME
AND NUM_ROWS > 0
AND ROUND ( (DELETES + UPDATES + INSERTS) / NUM_ROWS * 100) >= 10
AND OWNER IN ('OWNER_NAME’')
ORDER BY 3 desc;
but the query is displaying me output with stale % more than 100 and also statistics is not gathered for few of the tables listed by this query.
Thanks and Regards,
Alex AugustineAs far as I know, there is nothing to calculate here. Of course you can measure it. But what exactly do you want to achieve?
-
How to calculate percentage and difference of two values in matrix report in ssrs 2008
Hi everyone,
DB--SQL server
SSRS-2008
I am creating matrix report with grouping on WEEK and Fiscalyearweek,
I need to calculate of difference between FY14W01,FY15W01 ande percentage of those..
how to calculate in ssrs level.
Thank You, Manasa.VHi veerapaneni,
According to your description, you want to calculated the increment percentage and difference between two fiscal year week within each week. Right?
In this scenario, since we need to do calculation based on values between dynamically generated cells, we can't simply use expression to achieve this goal. In this scenario, we need to use custom code to record the value for fiscal 14 and fiscal 15, then
we can calculate the difference and percentage within the column group. We have tested your case in our local environment, please refer to the steps and screenshots below:
1. Add the custom code below into the report (you may need to modify the data type based on your scenario:
Public Shared Value1 as Integer
Public Shared Value2 as Integer
Public Shared previous as string
Public Shared previousweek as string
Public Shared Function GetValue(Value as Integer,product as String,Week as String) as Integer
If product =previous and Week =previousweek Then
Value2=Value
Else
previous=product
previousweek=Week
Value1=Value
End If
return Value
End Function
Public Shared Function GetPct()
return (Value2-Value1)/Value1
End Function
Public Shared Function GetDiff()
return Value2-Value1
End Function
2. Design the matrix like below:
3. The result look like below:
If you have any question, please feel free to ask.
Best Regards,
Simon Hou -
How to calculate percentage in alv
hi guru,
i have 2 vaues one is onspec total = 543 . 00
grand total = 1098.00
how i caculate percentage means i want (543 / 1098)*100
help me in alv ....
thanksI too have searched for a complete answer. I have managed to calculate the percentage and update the subtotal line, but cannot force this data to the grid on first display. I set the DO_SUM = 'X' in the field category and the SUBTOT = 'X' in the sort table. The following code will change the subtotal line. Any help with forcing the new subtotal to appear in grid at first display will be greatly appreciated.
Get the sort criteria before subtotaling changes
CALL METHOD G_GRID->GET_SORT_CRITERIA
IMPORTING
ET_SORT = GT_SORT.
Get the subtotal structure
CALL METHOD G_GRID->GET_SUBTOTALS
IMPORTING
EP_COLLECT00 = TOTAL
EP_COLLECT01 = SUBTOTAL.
ASSIGN TOTAL->* TO <TOTAL>.
ASSIGN SUBTOTAL->* TO <SUBTOTAL>.
CLEAR W_PLNHR.
Recalculate the % done in subtotal line
LOOP AT <SUBTOTAL> INTO WA_TOT.
IF WA_TOT-PLNHR > 0.
WA_TOT-PLNPR = WA_TOT-ESTHR / WA_TOT-PLNHR * 100.
ELSE.
WA_TOT-PLNPR = 0.
ENDIF.
WA_TOT-GJAHR = SGJAHR.
MODIFY <SUBTOTAL> FROM WA_TOT INDEX SY-TABIX.
ENDLOOP. -
How to calculate the monthly percentage of the goods delivered
hi all,
In my requirement i have to count the number of goods delivered to the customer per year and i have the calculate the percentage of goods delivered monthly.please help me .Hello Duygu,
restrict the original cost keyfigure with a variable which is based on fiscal period (this will be actual cost). And then create a new keyfigure(copy of original keyfigure) and use same variable but in detail of restriction use -1 for offset( this will be previous). And then define a new formula and subtract actual from previous or opposite)
Sarhan.
Maybe you are looking for
-
ST02 Export / Import buffer and directory entries
What would cause the number of (Export / Import) directory entries to steadily increase in ST02 until there were none left. I currently have the directory size set to 30,000 and over the course of about 7 days they are all used up and then I have ext
-
My desktop is now cluttered with these 2 files. I have tried everything and cant stop it..They are easy to delete so just need to figure this out.
-
Mysterious where clause with japanese
enviroment: PL/SQL Develope, Version 7.1.0.1337, Windows XP Professional 5.1 Build 2600 (Service Pack 2) Here is the problem, when i add a where clause with japanese, the data evaporated: SQL> select * from ja_test; EXECUTABLE_NAME DESCRIPTION XX00MR
-
BAPI/FM for reconnection and stop disconnection process in SAP ISU/CCS
Hi, If the disconnection has been carried out, then call the function module to start the reconnection process. let me know if ther is a BAPI/FM to carry out reconnection /disconnection Regards Shiva
-
Story not recognizing a character in the Outline
I imported a Word script, (that was exported from Buzzword), and one of my characters is not showing up as a coloured dot in the Outline pane. I've rewritten the character name and ensured it's set as a Character from the type menu, but no luck. I ha