Expression to find value for previous year SSRS

Hi
I need some help with expressions.I need a report that shows calcul of a field for current year as well as previous year respecting this rule expression(Last-Last Previous)/Last Previous*100 (I work with MDX Query and i work with SSRS 2008).
Also the report runs on a Year Parameter. Below is an example for the result
for example i selected the years 2010 2011 2012 i can select another years because i have the report runs on  a Year Parameter
year
Data 2010 2011 2012
hp 14 25 30
Dell 17 18 20
and the result i want
year
Data 2010 2011 2012 2011/2012
hp 14 25 30 0.002 (Last -Last Previous)/(last Previous*100) =(30-25)/(25*100)
Dell 17 18 20 0.0040
Thanks a lot

Hi Yassir,
Please find the RDL code, save the code into .RDL and run it
<?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>
<Tablix Name="matrix1">
<TablixCorner>
<TablixCornerRows>
<TablixCornerRow>
<TablixCornerCell>
<CellContents>
<Textbox Name="textbox3">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontFamily>Tahoma</FontFamily>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>textbox3</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>1in</Width>
</TablixColumn>
<TablixColumn>
<Width>1in</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.21in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="textbox2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Sum(Fields!value.Value)</Value>
<Style>
<FontFamily>Tahoma</FontFamily>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>textbox2</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>
<DataElementOutput>Output</DataElementOutput>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox16">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=((last(Fields!value.Value) -Code.GetValueByKeyValue(Fields!keyvalue.Value)) /Code.GetValueByKeyValue(Fields!keyvalue.Value))*100</Value>
<Style>
<FontFamily>Tahoma</FontFamily>
<Format>f2</Format>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox16</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>
<DataElementOutput>Output</DataElementOutput>
</TablixCell>
</TablixCells>
</TablixRow>
</TablixRows>
</TablixBody>
<TablixColumnHierarchy>
<TablixMembers>
<TablixMember>
<Group Name="matrix1_year">
<GroupExpressions>
<GroupExpression>=Fields!year.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!year.Value</Value>
</SortExpression>
</SortExpressions>
<TablixHeader>
<Size>0.21in</Size>
<CellContents>
<Textbox Name="year">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!year.Value</Value>
<Style>
<FontFamily>Tahoma</FontFamily>
<FontWeight>Bold</FontWeight>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>year</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>#6e9eca</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<DataElementOutput>Output</DataElementOutput>
<KeepTogether>true</KeepTogether>
</TablixMember>
<TablixMember>
<TablixHeader>
<Size>0.21in</Size>
<CellContents>
<Textbox Name="Textbox4">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<FontFamily>Tahoma</FontFamily>
<FontWeight>Bold</FontWeight>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox4</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>#6e9eca</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
</TablixMember>
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<Group Name="matrix1_data">
<GroupExpressions>
<GroupExpression>=Fields!data.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!data.Value</Value>
<Direction>Descending</Direction>
</SortExpression>
</SortExpressions>
<TablixHeader>
<Size>1in</Size>
<CellContents>
<Textbox Name="data">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!data.Value</Value>
<Style>
<FontFamily>Tahoma</FontFamily>
<FontWeight>Bold</FontWeight>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>data</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<BackgroundColor>#6e9eca</BackgroundColor>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember />
</TablixMembers>
<DataElementOutput>Output</DataElementOutput>
<KeepTogether>true</KeepTogether>
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<RepeatColumnHeaders>true</RepeatColumnHeaders>
<RepeatRowHeaders>true</RepeatRowHeaders>
<DataSetName>DataSet1</DataSetName>
<Top>1.20333in</Top>
<Left>0.10833in</Left>
<Height>0.42in</Height>
<Width>3in</Width>
<Style />
</Tablix>
<Textbox Name="textbox1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Get the last previous value</Value>
<Style>
<FontFamily>Tahoma</FontFamily>
<FontSize>12pt</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>
<ZIndex>1</ZIndex>
<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="Textbox7">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>data</Value>
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox7</rd:DefaultName>
<Style>
<Border>
<Color>White</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>1in</Width>
</TablixColumn>
<TablixColumn>
<Width>1in</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.25in</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="previous">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Sum(Fields!previous.Value)</Value>
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>previous</rd:DefaultName>
<Style>
<Border>
<Color>White</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="Textbox21">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Code.AddKeyValue(Fields!keyvalue.Value, last(Fields!previous.Value))</Value>
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox21</rd:DefaultName>
<Style>
<Border>
<Color>White</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="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="year1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!year.Value</Value>
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>year1</rd:DefaultName>
<Style>
<Border>
<Color>White</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>
<TablixMember>
<TablixHeader>
<Size>0.25in</Size>
<CellContents>
<Textbox Name="Textbox20">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox20</rd:DefaultName>
<Style>
<Border>
<Color>White</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
</TablixMember>
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<Group Name="data">
<GroupExpressions>
<GroupExpression>=Fields!data.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!data.Value</Value>
</SortExpression>
</SortExpressions>
<TablixHeader>
<Size>1in</Size>
<CellContents>
<Textbox Name="data1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!data.Value</Value>
<Style>
<Color>White</Color>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>data1</rd:DefaultName>
<Style>
<Border>
<Color>White</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>DataSet2</DataSetName>
<Top>0.43944in</Top>
<Left>0.29667in</Left>
<Height>0.5in</Height>
<Width>3in</Width>
<ZIndex>2</ZIndex>
<Style>
<Border>
<Color>White</Color>
<Style>None</Style>
</Border>
</Style>
</Tablix>
</ReportItems>
<Height>1.76333in</Height>
<Style />
</Body>
<Width>5.10833in</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>87cd8154-60ce-43ca-a678-39a5c1bfeb15</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet2">
<Query>
<DataSourceName>DataSource1</DataSourceName>
<QueryParameters>
<QueryParameter Name="@Year">
<Value>=Parameters!Year.Value</Value>
</QueryParameter>
</QueryParameters>
<CommandText>select * from
SELECT data, year , value AS previous,cast(year as varchar)+ data as keyvalue,row_number() over(partition by data order by year desc) yeardesc
FROM (SELECT 'HP' DATA, 2010 year, 14 value
UNION
SELECT 'HP' DATA, 2011 year, 25 value
UNION
SELECT 'HP' DATA, 2012 year, 30 value
UNION
SELECT 'Dell' DATA, 2010 year, 17 value
UNION
SELECT 'Dell' DATA, 2011 year, 18 value
UNION
SELECT 'Dell' DATA, 2012 year, 20 value
) AS t
WHERE year IN (@Year)
)t1
where yeardesc &lt;&gt; 1
order by year asc</CommandText>
</Query>
<Fields>
<Field Name="data">
<DataField>data</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="year">
<DataField>year</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="previous">
<DataField>previous</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="keyvalue">
<DataField>keyvalue</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="yeardesc">
<DataField>yeardesc</DataField>
<rd:TypeName>System.Int64</rd:TypeName>
</Field>
</Fields>
</DataSet>
<DataSet Name="DataSet1">
<Query>
<DataSourceName>DataSource1</DataSourceName>
<QueryParameters>
<QueryParameter Name="@Year">
<Value>=Parameters!Year.Value</Value>
</QueryParameter>
</QueryParameters>
<CommandText>SELECT data, year, value,cast(year as varchar)+data keyvalue
FROM (SELECT 'HP' DATA, 2010 year, 14 value
UNION
SELECT 'HP' DATA, 2011 year, 25 value
UNION
SELECT 'HP' DATA, 2012 year, 30 value
UNION
SELECT 'Dell' DATA, 2010 year, 17 value
UNION
SELECT 'Dell' DATA, 2011 year, 18 value
UNION
SELECT 'Dell' DATA, 2012 year, 20 value) AS t
WHERE year IN (@Year)</CommandText>
</Query>
<Fields>
<Field Name="data">
<DataField>data</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="year">
<DataField>year</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="value">
<DataField>value</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="keyvalue">
<DataField>keyvalue</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<ReportParameters>
<ReportParameter Name="Year">
<DataType>String</DataType>
<DefaultValue>
<Values>
<Value>=2010</Value>
<Value>=2011</Value>
<Value>=2012</Value>
</Values>
</DefaultValue>
<Prompt>Year</Prompt>
<ValidValues>
<ParameterValues>
<ParameterValue>
<Value>2010</Value>
<Label>2010</Label>
</ParameterValue>
<ParameterValue>
<Value>2011</Value>
<Label>2011</Label>
</ParameterValue>
<ParameterValue>
<Value>2012</Value>
<Label>2012</Label>
</ParameterValue>
</ParameterValues>
</ValidValues>
<MultiValue>true</MultiValue>
</ReportParameter>
</ReportParameters>
<Code>Public PersSal as New System.Collections.HashTable()
Function ClearList(SomeValue as String) as String
PersSal.Clear
Return SomeValue
End Function
Function AddKeyValue(KeyValue as String, Value as Decimal) as Decimal
Try
PersSal.Add(KeyValue, Value)
Return Value
Catch ex as Exception
End Try
End Function
Function GetValueByKeyValue (ByVal Key As String) As Decimal
For Each clsPair As System.Collections.DictionaryEntry In PersSal
If clsPair.Key.ToString() = Key Then Return clsPair.Value
Next
End Function</Code>
<Language>en-US</Language>
<ConsumeContainerWhitespace>true</ConsumeContainerWhitespace>
<rd:ReportUnitType>Inch</rd:ReportUnitType>
<rd:ReportID>53660ed8-b969-46cf-960b-2ccb14abf7e7</rd:ReportID>
</Report>
Thanks
Prasad
Mark this as Answer if it helps you to proceed on further.

Similar Messages

  • How to get monthwise opening qty / value for previous years

    I do not get the month wise opening quantity and values for the items for the previous years using the below query. How i can modify this query to get opening qty / value of any year less than current year.
    Yogesh
    SELECT OPN_ITEM_CODE,
    ---------------------------------------OPENING QTY---------------------------------------------------
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),3)THEN ROUND(OPSTK,3) ELSE NULL END)APR_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),4)THEN ROUND(OPSTK,3) ELSE NULL END)MAY_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),5)THEN ROUND(OPSTK,3) ELSE NULL END)JUN_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),6)THEN ROUND(OPSTK,3) ELSE NULL END)JUL_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),7)THEN ROUND(OPSTK,3) ELSE NULL END)AUG_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),8)THEN ROUND(OPSTK,3) ELSE NULL END)SEP_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),9)THEN ROUND(OPSTK,3) ELSE NULL END)OCT_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),10)THEN ROUND(OPSTK,3) ELSE NULL END)NOV_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),11)THEN ROUND(OPSTK,3) ELSE NULL END)DEC_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),12)THEN ROUND(OPSTK,3) ELSE NULL END)JAN_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),13)THEN ROUND(OPSTK,3) ELSE NULL END)FEB_OPQ,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),14)THEN ROUND(OPSTK,3) ELSE NULL END)MAR_OPQ,
    ---------------------------------------OPENING VALUE----------------------------------------------------
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),3)THEN ROUND(OPVAL,3) ELSE NULL END)APR_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),4)THEN ROUND(OPVAL,3) ELSE NULL END)MAY_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),5)THEN ROUND(OPVAL,3) ELSE NULL END)JUN_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),6)THEN ROUND(OPVAL,3) ELSE NULL END)JUL_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),7)THEN ROUND(OPVAL,3) ELSE NULL END)AUG_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),8)THEN ROUND(OPVAL,3) ELSE NULL END)SEP_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),9)THEN ROUND(OPVAL,3) ELSE NULL END)OCT_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),10)THEN ROUND(OPVAL,3) ELSE NULL END)NOV_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),11)THEN ROUND(OPVAL,3) ELSE NULL END)DEC_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),12)THEN ROUND(OPVAL,3) ELSE NULL END)JAN_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),13)THEN ROUND(OPVAL,3) ELSE NULL END)FEB_OPV,
    SUM(CASE WHEN SL_DT < ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),14)THEN ROUND(OPVAL,3) ELSE NULL END)MAR_OPV
    FROM( SELECT SL_ITEM_CODE OPN_ITEM_CODE, SL_DT,
    SUM(DECODE(SL_RCVD_ISSD,'R',1,'I',-1)*SL_QTY_BU/IU_CONV_FACTOR/IU_MAX_LOOSE_1)OPSTK,
    SUM(DECODE(SL_RCVD_ISSD,'R',1,'I',-1)*SL_VAL_1)OPVAL
    FROM OS_STK_LEDGER, OM_ITEM_UOM
    WHERE SL_ITEM_CODE = IU_ITEM_CODE
    GROUP BY SL_ITEM_CODE, SL_DT
    GROUP BY OPN_ITEM_CODE

    it think you need to look for [lag and lead|http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/analysis.htm#sthref1753]

  • Customizing setting 'Recalculate depreciation for previous years'

    Dear Experts,
    I have requirement where for tax depreciation areas we want the system to recalculate the depreciation for previous years. For e.g.
    Asset acquired on 7/1/06 with value 10000
    Useful life: 5 years
    Take over date in asset accounting: 9/30/2008
    With the above example, I want the system to show me depreciaiton values for the years 2006 and 2007 also in transaction AW01N (Asset Explorer), apart from 2008.
    In FI-AA customizing, I have enabled the relevant depreciation areas for recalculation in the node 'Recalculate Depreciation for Previous Years' (Transaction OAYF).
    However, when I create the legacy asset and maintain the takeover values, the system just shows me depreciation for 2008 and onwards.
    Is there something I am missing? Please advice. I have searched the SAP help and SAP notes, but did not find anything.
    Regards,
    Vishal.

    This is not possible.  When you takeover an asset using AS91, it is creating an ANLC entry for that year only.  2008 in your case.  Regardless of when the asset was originally acquired, SAP will only let you report on it back to 2008.
    This concept is no different than any other FI/CO legacy conversion.  If the customer is going live on Jan 1st 2008 but they want to do monthly comparison reporting in SAP (Jan 07 and Jan 08), then they need to convert 2007 data.  If they want 2006, they need to load that too.  Etc.
    For FI-AA, if the customer wants to view data back to 2006 you would have to change the takeover date to that year and adjust the data as well (accumulated depreciation).
    -nathan

  • Close budget for previous years

    Hi,
    The system Iu2019m working on has commitments management active, so when I create a purchase requisition or purchase order, the budget is affected. Iu2019ve noticed that the field that determines the year relevant for budget availability is the delivery date (EEIND).
    So if I make a purchase requisition today, with a delivery date of 2007, for instance, it will affect the budget from 2007 year. I donu2019t want this to happen. Is there any way to u201Ccloseu201D the year budget and donu2019t allow any more values to affect the budget for previous years?
    Thanks for any help.

    Hello,
    Please check the budget profile.
    In budget profile, you will have how many previous years or future years you can budgeted. Try to reduce one year for previous years.
    Regards,
    Ravi

  • Reference a value of previous year in a Script Logic

    Hi,
    I need to reference a value of previous year to that I have in a Script Logic.
    I've tried it with "%YEAR% (-1)", but "%YEAR%" refers to the current year and doesn't refer to the year that I have in the Script Logic, that is, if I pass "2006.DEC " to Script Logic, the system returns me in "%YEAR%" the value "2010".
    What syntax should I use?
    Regards,
    Miguel.

    Hi
    The  Damien's suggestion is the correct one for BPC 7.0 NW to get the offset of the passed-in Time's member.
    So you have properties in your Time dimension that store the prior year of current member or the next year of current member or next 2 years of current member and etc.
    Then reference them in you logic something right this
    ID : 2008.JAN
    NEXT: 2009.JAN
    PRIOR: 2007.JAN
    *WHEN TIME
    *IS %TIME_SET%
    *REC(FACTOR=1, TIME=TIME.PRIOR)
    *ENDWHEN
    Additional information,
    %YEAR% in BPC NW reflects the time on the server which is different from the BPC MS.
    BPC 7.5 NW has a better function to handle this: TVML.
    Halomoan

  • 50% credit on capital goods for previous year is not availed

    Dear All,
    The go-live date for my client was 01.10.2009. Now, in Apr, 2010 when the client is trying to get the 50% credit on Capital Goods (t. Code j2i8),  system is not generating any data of the previous year. (From Oct, 09 to Mar'10).  However, if we see the GL Balace for 'Cenvat On Hold A/c' as on 31.03.2010, it shows a  balance of Rs. 2.50 lakhs approximately.
    Can you please tell me why system is not showing any details through j2i8 for previous year?
    Thanks & Regards,
    Reshma

    Hello,
    The settings before 01.04.2010 were same.  However, after thorough checking of the GL A/cs, I have following observations -
    1) Plant 1 - Balance as on 31.03.2010 in Cenvat on Hold A/c -Rs. 195080. It is upload balance & t.code used is FBVB
        There are some more transctions in this A/c which are  reversed due to wrong entries.
        Balance in Excise Duty RG 23 C as on 31.03.2010 - NIL
    2) Plant 2 - Balance in Cenvat on Hold A/c as on 31.03.2010 is  Rs. 166701. Again this is an upload balance with FBVB
        Balance in Excise Duty RG 23 C as on 31.03.2010 - Rs. 56931.62
    3) Plant 3 -  No upload balance.  All the transactions are routed through J1IEX except 1 from FB01
        Balance as on 31.03.2010 - Cenvat On Hold A/c - Rs. 86876.06
                                                     ED RG 23C  - NIL
    Hence, would like to know -
    1) Any separate procedure to take the credit of upload entries?
    2) If the Balance in ED RG 23C A/c is NIL, will it affect on taking credit?
    Thanks & Regards,
    Reshma

  • - How to Display Sales Qty & Value for This Year & Last Year in 2 Columns -

    Dear All,
    I'm having trouble in extracting the last year figures based date entered. I'm actually would like to create a query where I'm able to know the "TOP 10 item sold based item category". I've created a query, which show the top10 item sold (total quantity & value) for this year, but not able to display the last year figure (quantity). Please advise & thanks for your help and time.
    SET ROWCOUNT 10
    SELECT T1.ItemCode, T2.ItemName, T3.ItmsGrpNam, SUM(T1.Quantity) as "Total Qty Sold", SUM(T1.TotalSumSy) as "Total Amount"
    FROM ODLN T0  INNER JOIN DLN1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod
    WHERE T0.DocDate >='[%0]' AND  T0.DocDate <='[%1]' AND  T3.ItmsGrpNam ='[%A]' 
    GROUP BY T1.ItemCode, T2.ItemName, T3.ItmsGrpNam
    ORDER by SUM(T1.Quantity) DESC
    I wish to have the output as follow
    Item   Qty (2008)  Qty (2007)    Value(2008)   Value(2007)
    A       300             150               1000                      500
    B       250             300                 800                      650
    C       100             250                 700                      550
    Currently, My results display:
    Item   Qty (2008)  Value(2008) 
    A       300             1000                     
    B       250               800                     
    C       100               700                     
    Cheers,
    Serene

    Hi,
    if you want more flexible, you could try this modified Istvan's query:
    SELECT top 10 T1.ItemCode, T2.ItemName, T3.ItmsGrpNam,   SUM(T1.Quantity) as "Total Qty Sold",
      SUM(T1.TotalSumSy) as "Total Amount" ,
      (select sum (r.Quantity) from ODLN h
         inner join DLN1 r on h.DocEntry=r.DocEntry  
         where h.DocDate>='[%4]' and h.DocDate<='[%5]'
             and r.ItemCode=T1.ItemCode) '2007 Sold',
      (select sum (r.TotalSumSy) from ODLN h
         inner join DLN1 r on h.DocEntry=r.DocEntry  
         where h.DocDate>='[%6]' and h.DocDate<='[%7]'
             and r.ItemCode=T1.ItemCode) '2007 Amount'
    FROM ODLN T0 INNER JOIN DLN1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod
    WHERE T0.DocDate >='[%0]' AND T0.DocDate <='[%1]' AND T3.ItmsGrpNam between '[%2]'  and '[%3]'
    GROUP BY T1.ItemCode, T2.ItemName, T3.ItmsGrpNam
    ORDER by SUM(T1.Quantity) DESC
    Rgds,

  • ORD to AUC settlement for previous year

    Hi All,
    We have a scenario wherein some expense exists on the Internal order for 2014. The Asset fiscal year has been changed to 2015.
    While trying to settle the ORD to AUC for current year, we get a message to do the settlement for previous year.
    I checked the SAP notes, it recommended:
    1. To do a PRE settlment to Cost Center/receiver in 2014,
    2. Manual reposting of cost from the receiver to ORD in 2015, and
    3. AUC settlement in 2015.
    Please suggest if there is any other way to do it with/without opening the previous fiscal year.

    Hi Pankaj,
    Check the settle parameters of the order, have you defined settlement type as "periodic settlement" for the asset. If yes, add another line for full settlement for it. Then do settlement for 2015 with processing type as "Automatic", then system will post to 2015 for the asset.
    Regards,
    Mukthar

  • How we create Variable for Previous year for COPA reports

    Hi Guruss,
    I am making a COPA report for Current year comparison with previous year from KE31. For 1st column I have created the Variable for current year (which works perfectly) now in 2nd column i need the actual data pertaining to previous. So can any one please guide me how to create the variable for previous year.
    Thanks

    Thanks Jagannadha,
    I have create the variable for current year on KE3E. but i am confuse how i create the variable for previous year on KE3E.
    Waiting for reply.

  • MBST finds document in VBFA and accesses LIKP for previous year document

    Hi all,
    I don't know if this is the right place to post. As an ABAP developer, I'll put my query here :
    Scenario : In MBST, for a particular document type and year 2012, it displays error and says "No Authorization for shipping point X", though the document is posted againt another plant/shipping point Y. This material was posted for X in 2011. And we are not able to determine why MBST is picking up 2011 record.
    Analsysis :
    On debugging, we found -
    There is an FM "WS_FIND_ORIGINATE_DOCUMENT" called in program LMBDFU01.
    This FM is called on pressing enter on the initial screen in MBST i,e before we press Save.
    Here there is a query to where it finds the document in VBFA :
    SELECT * FROM VBFA APPENDING TABLE XVBFA
                             WHERE     VBELN   = MBVBFA-MBLNR
                             AND     ( VBTYP_V = 'J' OR VBTYP_V = 'T' )
                             AND       ERDAT LIKE BELJAHR
                             AND       VBTYP_N = 'i'.
    Here it doesnt find document for 2012, so it searches for 2011 (subtracts 1 from the year passed in MBST).
    It finds a document for 2011 in VBFA and picks up the corresponding VBELV and passes it into VBELN in LIKP and hence fetches the previous year record and plant and authorizes the user against it.
    In ideal condition, there is no document fetched for any year from VBFA and no LIKP is accessed. Any idea on why there could be a document present in VBFA for this document ? And how I can prevent from selecting this record as this is standard.
    Thanks and Regards
             Vivek

    Hi,
    Thanks for your reply,
    Yes we have migrated on 1.4.2009 and test migration have been performed .
    But my client is to close books of accounts so it is having the said requirement of vendor to vendor transffer,kindly suggest me other alternative
    Regards
    vijay

  • Depreciation run for previous years

    Hi Experts,
    I am in Development system where the depreciation run has not been carried out since 2007 as per OAAQ. Now when I try posting depreciation for year 2008 period 1, it throws this error "You can only post in new year after closing previous year". However, 2007 is already closed.
    Again when I try to close the FY in AJAB, it throws this error "No year end close is necessary for co. code XXXX".
    Also, I don't find any table entries for TABA and as per table T093b 2007 is the closed FY.
    So, my question is how can I carry out the depreciation run for all these years to bring the system to current FY.
    Additional information you might require is OB52 is having period open from 1/2014 to 12/2016. and Planned ordinary depreciation has been carried out for some of assets till 2009 as I can see in table ANLC.
    Thanks in advance
    Regards
    Sukham

    Hi Sukham,
    ok, the problem is that you have values for the last posted in T093D, which may come from a legacy data takeover.
    You have 2 options right now:
    1) Implement and run the correction program from note 144441          
    2) Either clear or set the last posted depreciation period in the IMG for FI-AA legacy transfer to 12 (or use the correction program from note 26073)
    Regards,
    Markus

  • MDX to fetch record from 1st of current month to 5th of next month and same for previous year

    In my date dimension I have a attribute CalendarDate. I do have a hierarchy [Date].[Year].[Quarter].[Month].[CalendarDate] as well. I need to fetch data starting from 1st working day of current month to 5th working day of next month by MDX. I do have a attribute
    to filter working day as IsWorkingDay. How can we get a dynamic MDX that will find the current month first and than it will filter the record from 1st working day of current month to 5th working day of next month. And same for the previous year same month
    to compare.
    Thanks in advance!
    Palash

    Hi P,
    You can use a calculated member to dynamically add all the days in the current month and the first 5 in the following month.  You will need to change measure, cube and hierarchy names.
    with member measures.ThisMonthAnd5 as 
    sum([Date].[Year].parent.children,Measures.[Sales])
    +sum(Head([Date].[Year].parent.nextmember.children,5),Measures.[Sales])
    select 
    {Measures.[Sales]
    ,Measures.ThisMonthAnd5
    } on 0,
    non empty [Date].[Year].[CalendarDate]  
    on 1
    from MyCube
    Richard

  • Bi 7.0 SD report for previous year, month, current month, rolling 30days.

    I have Sales document type in rows and in column, I have no of sales documents.
    Now, I need sales documents in rows and no of sales documents in columns according to
    created on date: 0calday of types as follows
    List of columns:
    Previous year    last quarter   Current quarter     Current month    30 days rolling.
    How do I define these RKFs.. do we have standard date variables for RKF.
    Thanks
    Jeff

    Hi ,
    You dont have a standard date variable
    I have the solution for ur problem
    here u can go for creation of variable for column KF and assign the value for each sales document type = 1 by using a customer exit
    Pls assign some points if answer is helpfull
    Regards ,
    Subash Balakrishnan

  • Balance for previous years

    I have the following requirement:
    A user enters a Fiscal Period.  On our report we want to define key figures which show values as follows:
    Our Financial year is from 1st January u2013 31st December with 16 posting periods (K4 variant)
    Fiscal Period: 042007 u2013 entered by user
    1.     Balance for beginning of reporting year and end of previous year
    2.     Balance for beginning of previous year and end of year before previous
    Therefore for the example:
    1.     Balance 01.01.2007 and Balance 31.12.2006
    2.     Balance 01.01.2006 and Balance 31.12.2005
    How can I do this can I offset if so how and if not do I need to write an exit if so how? Thanks

    Hi Varun,
    Which period you want to run the report? Please let us know and also share screen shot.
    Regards
    Mukthar

  • Pcr To Get The Wage Type Value From Previous Years Master Data Records

    Hi
    I have an issue related to pcr.  I want to get the value of a wage type from previous year and it has to be added to another wage type.  Tried to write pcr by using the operation TABLE.  But i am not able to get the previous years data.  Request to help in writing the PCR for the issue.
    Thanks
    EKP Yadav

    1 - Create an "Information WT" that will be saved into RT but that has no impact on net pay.
    2 - Create a PCR that will be activated on the last pay of the year to read the WT you want and transfer it's information into your Information WT.
    3 - Create a PCR that will read the last payroll results (activated with function PLRT) and transfer into the Input Table (IT) the Information WT.

Maybe you are looking for

  • SB live 5.1 not working even with original new installation cd.Pls H

    Hi, I have purchased just last week a brand new PC with intel 95 chipset asus mbd P5-GL-MX having on -board azalia sound component.Along with just got box packed Li've 5. sound card. This has in pack original installation cd.after installing card and

  • Importing scanned photos from DVD

    I just downloaded PSE 9 and I'm trying to import three dvd's of scanned photos.  PSE 9  fails to import the 2nd and 3rd dvd's becasue the photo ID is the same on disc 2 and 3 (each photo is just sequentially numbers 1,2,3,etc.)  Can someone please te

  • Handling unit detail report against reservation Number (MB21)

    Hi experts for Internal material requiremnt we create reservation from MB21.then against that reservation number we transferred material from Ware house management system in form of Handling unit. As per process against that resrvation number system

  • Sending of RFQ Form through Mail

    Hi all, I have requirement where in .... When i create a RFQ(in tcode ME41) or make any changes (in Tcode me42). The RFQ Form should get converted into PDF and go as an attachment in the mail to the vendor. Can anybody help...regarding this!! regards

  • JSP rendering hangs

    Hi           I am facing strange problem here,           Here In login.jsp file uses jsp:forward to load next page having frameset of           two frames.           Now one of frames after rendering on server doesn't get displayed on           brows