Using an expression in SSRS to display rolling 12 month and year to date volumes

I need some help in writing an expression in SSRS. I have a table that contains date columns and rows that contain different types of data groups. (e.g. total number of items received during the month, total dollars for the month, etc.) I want to add two
new columns to the end of the report that will display a rolling twelve month total for each of the different rows of data. Plus a column that would show year to date totals for the same rows.
I was thinking I could accomplish this by adding expressions for each row in the new 'rolling twelve month' and 'YTD' columns in my report however, I'm not sure how to structure the expressions to achieve this.
Here is an example of how my report currently looks. (I added a pipe delimeter in case the formatting changes once this is submitted.)
                         Jan-2014 | Feb-2014 | Mar-2014 | Apr-2014 | Rolling 12 mth | YTD
Items received     100 | 35 | 45 | 12 | 192 | 192
Dollars                $50.00 | $25.00 | $120.00 | $15.00 | $210.00 | $210.00
Any guidance you can provide would be appreciated.
Thank you  

This example shows how to get what you need. It'll take modifying your query to add two cased columns onto the end.
DECLARE @forumTable TABLE (periodYear INT, periodMonth INT, periodMonthName VARCHAR(12), periodDollars MONEY, periodItems INT)
DECLARE @i INT = 0
SET NOCOUNT ON
WHILE @i < 24
BEGIN
INSERT INTO @forumTable (periodYear, periodMonth, periodMonthName, periodDollars, periodItems)
VALUES (YEAR(DATEADD(MONTH,-@i,GETDATE())), Month(DATEADD(MONTH,-@i,GETDATE())), DATENAME(MONTH,DATEADD(MONTH,-@i,GETDATE())), 1000-@i, 100-@i)
SET @i = @i+1
END
SET NOCOUNT OFF
SELECT *,
CASE WHEN CONVERT(VARCHAR,periodYear) + '-' + CONVERT(VARCHAR,periodMonth) + '-01' > DATEADD(MONTH,-12,GETDATE()) THEN periodItems ELSE 0 END AS ytdItems,
CASE WHEN CONVERT(VARCHAR,periodYear) + '-' + CONVERT(VARCHAR,periodMonth) + '-01' > DATEADD(MONTH,-12,GETDATE()) THEN periodDollars ELSE 0 END AS ytdDollars
FROM @forumTable

Similar Messages

  • Display of Month and year in Y-axis of horizontal bar chart

    Hi,
    We are using Webi XI R2 version. Could you please let me know how we can display date in chart.  I am having objects as Month name (July, Aug etc) and year (2009). I want to display on the Y-axis as Jul-09, Aug-09
    Please advise.
    Kindly let me know if any further information is required on the same.
    Thanks in advance,
    Eswar
    Edited by: Eswar Rao on Sep 6, 2010 1:31 PM

    Hi,
    Now I understand your problem a little bit better.
    If you do not have a measure you could try and create one.
    One that comes to mind that will be usefull here is the number of days till task finish.
    Use either the
    DaysBetween(CurrDate();[task_end_date])
    , which will change as the report gets older.
    or the refresh date of dataprovider, which will stay as it was after refresh.
    However I'm not sure that will get you the exact layout you are looking for.
    Since normally that number of days will then go on the y-axis, not the task end date.
    You could try a few chart options with the ending month as a dimension on the y-axis.
    Or ask the users if they can live with this different indication of how long it will take till a task finishes.
    Hope this helps,
    Marianne

  • Loop through month and year till date while using a merge statement

    Hello Guys,
    I have 2 tables with the following datas in them:-
    Company
    CompanyId CompanyName
    1                 Company1
    2                 Company2
    3                 Company3
    Employees
    EmployeeId EmployeeName CompanyId StartDate
    1                  Employee1        1                 12/21/2011
    2                  Employee2        1                 01/20/2012
    3                  Employee3        2                 03/23/2012
    4                  Employee4        2                 07/15/2012
    5                  Employee5        2                 01/20/2013
    6                  Employee6        3                 12/17/2013
    Now i want to check, How many people were recruited in the team in the specified month and year? I have the storage table as follows:-
    RecruiterIndicator
    CompanyId Year Month EmployeeRecruited
    1                 2011 12      1
    1                 2012 1        1
    2                 2012 3        1
    2                 2012 7        1
    2                 2013 1        1
    3                 2013 12      1
    This should be a merge stored procedure that should update the data if it is present for the same month year and company and insert if that is not present?
    Please help me with this
    Thanks
    Abhishek

    It's not really clear where the merge to come into play. To get the RecruiterIndicator table from Employess, this query should do:
    SELECT CompanyId, Year(StartDate), Month(StartDate), COUNT(*)
    FROM   Employees
    GROUP  BY CompanyId, Year(StartDate), Month(StartDate)
    Erland Sommarskog, SQL Server MVP, [email protected]

  • I want to accumulate rain for the day, month and year; What formula can I use?

    I want to accumulate rain for the day, month and year; What formula or expression can I use.
    I am using a Rain Wise product that converts pulses to an analog value.  The Rain Wise device can be
    set to measure up to 1", 5", or 10".  I will be setting the unit to 10 inches in increments of 0.01 inches.
    What I would like to do is everytime the signal increments I would like to count it as 0.01 then after reaching
    a period of time whether it be a day or a month reset back to zero.
    Need some advise on this problem.
    Solved!
    Go to Solution.

    Hello Ryan,
    Lookout gets a Modbus over Ethernet signal which originates as a 4-20mA input to a Moxa Ethernet I/O Module (E1240) in the field.  In Lookout I created a ModbusEthernet Driver and a tag which scales 0 - 65534 RAW to 0-10 Eng.  [0 - 10 is inches of rain]  Also, another piece of information is that after the rain gauge maxes out at 10 inches it will zero out and start over.
    I though the accumulator was time based and took a sample over a specific time period, for instance, one sample every 30 seconds then accumulate.  If this is so then if I have 5 inches of rain and then it stopped raining, then 30 seconds latter it would sample, it would see 5 inches and add that to be 10 inches when actually it had only rained 5 inches. 
    I really need some help with this process,
    David Lopez
    City of Corpus Christi

  • Displaying dates from 1 to 31/30/28 depending on month and year

    Hi all,
    I am working on oracle 10g, how can i display set of dates from (1 to 30) depending on month and year eg, for nov month if i run the query.. the output should be:
    1
    2
    3
    30
    and this should be accomplished only by using SQL
    Regards,
    Sreekanth.

    something like:
    select level from dual
    connect by level <= to_number(to_char(last_day(to_date('NOV-2009', 'MON-YYYY')), 'DD'))
    /

  • List of Month and Year in SSRS report parameter?

    Hi, I have two parameters in my SSRS Report i.e. Month and Year. I want to show the list of all Months in dropdown and years for a particular range say 1995-Current Year.
    Can any one suggest me the query for how to get it to work.Thanks!!
    MCP

    I am not sure I what you're business needs are for this report.  You stated that you need the month and year for parameters.  If this is the case then there has to be a date and time column in which you can query against to provide both the month(s) and year.  In order to accomplish this using t-sql without querying an existing column would require a loop or cursor based approach,which can negatively impact performance, or a union statement specifying a string literal and the effort to write either of these would exceed the effort required to statically assign the parameter values in reporting services.  The below query shows how to statically create a query for each month and its ordinal position in the year and the same could be done with the year(s) 1995-2009, but this process involves more resources than assigning the static values for the parameters
    SELECT DATENAME(MONTH, 1 ) AS MONTH,
    1
    UNION
    SELECT DATENAME(MONTH, 2 ) AS MONTH,
    2
    UNION
    SELECT DATENAME(MONTH, 3 ) AS MONTH,
    3
    UNION
    SELECT DATENAME(MONTH, 4 ) AS MONTH,
    4
    UNION
    SELECT DATENAME(MONTH, 5 ) AS MONTH,
    5
    UNION
    SELECT DATENAME(MONTH, 6 ) AS MONTH,
    6
    UNION
    SELECT DATENAME(MONTH, 7 ) AS MONTH,
    7
    UNION
    SELECT DATENAME(MONTH, 8 ) AS MONTH,
    8
    UNION
    SELECT DATENAME(MONTH, 9 ) AS MONTH,
    9
    UNION
    SELECT DATENAME(MONTH, 10) AS MONTH,
    10
    UNION
    SELECT DATENAME(MONTH, 11) AS MONTH,
    11
    UNION
    SELECT DATENAME(MONTH, 12) AS MONTH,
    12
    David Dye

  • How to set filter criteria for month and year using in timestamp input field?

    Hi,
    I am using jdev 11.1.2.3,
    I have one problem with Report generation,,,,,,I have one report table which is in the form of VO(query based) and i want to search this table as month and year basis
    but in this table(query) that field having timestamp based value.. how to search with month name and year only.. Here i am using totally query base VO's for generating
    reports........ Can any one guide me.
    Thank You.

    You can use a inputdate, which allows you to selecte a moth, year and a day. Once the selection is made you convert it to only allow moth and date like
            <af:inputDate label="Label 1" id="id1" autoSubmit="true" value="#{bindings.myMonthYear1.inputValue}">
              <f:convertDateTime pattern="MM/yyyy"/> 
            </af:inputDate>
            <af:outputText value="Selected #{bindings.myMonthYear1.inputValue}" id="ot1" partialTriggers="id1"/>
    then you have a string holding month and year only. This value you split into two variables you or pass it as a whole parameter to the query and split it there.
    Another way is to add two static lovs one for month and one for year and use them to get to the filter values.
    Timo

  • Display month and year in dropdown list on selection screen

    Hi
      Can anyone tell me how to display months and year in a dropdown list on a selection screen?
      also please tell me how to get the first and the last dates upon selecting the month and year on the dropdown list.
    Month: January Year:2007 . 
    After selecting the required month and year, the first date and last date i.e '01.01.2007 - 31.01.2007' should be displayed on the right side.
    Reward Points assured..
    thanks,
    Chetan

    Hi..,
    <b>
    Just copy, paste and execute this program !!</b>
    type-pools: vrm.
    parameters : p_month(2) type n as listbox visible length 10,
    p_year(4) type n as listbox visible length 10.
    DATA : W_DATE type d, w_ldate type d.
    initialization.
    perform user_drop_down_list_fordt.
    perform user_drop_down_list_foryr.
    start-of-selection.
    concatenate p_year p_month '01' into w_date.
    call function 'BKK_GET_MONTH_LASTDAY'
      exporting
        i_date        = w_date
    IMPORTING
       E_DATE        = w_ldate
    write /: w_date,w_ldate.
    build user_drop_down_list
    form user_drop_down_list_fordt.
    data: name type vrm_id,
    list type vrm_values,
    value like line of list.
    data: t_months type t247 occurs 0 with header line.
    clear list. refresh list.
    name = 'P_MONTH'.
    select * into  table t_months
    from t247 where spras eq 'EN'.
    sort t_months ascending by mnr.
    loop at t_months.
    clear value.
    value-key = t_months-mnr.
    value-text = t_months-ltx.
    append value to list.
    endloop.
    Set the values
    call function 'VRM_SET_VALUES'
    exporting
    id = name
    values = list.
    endform.
    for year...
    form user_drop_down_list_foryr.
    data: name type vrm_id,
    list type vrm_values,
    value like line of list.
    clear list. refresh list.
    name = 'P_YEAR'.
    do 9999 times.
    clear value.
    value-key = sy-index.
    append value to list.
    enddo.
    Set the values
    call function 'VRM_SET_VALUES'
    exporting
    id = name
    values = list.
    endform.
    <b>
    Hope this solves ur problem..</b>
    regards,
    sai ramesh

  • Date concatenation using MONTH and YEAR

    Env : Oracle Reports 9I.
    I need to display reports based on dates.
    If the user enters in one field 'SEP' and in another '2005',
    how can I concatenate both the fields as one and then display
    all results for SEP 2005?
    The Table has a field called Eff_Date (of type Date)
    and containing values:
    Eff_Date
    ==============
    01-09-05
    02-09-05
    04-09-05
    05-09-05
    My code is
    SELECT col1,
           col2
    FROM   TableA
    Where  TRUNC(Eff_Date )=:MONTH  ?? PARAMETER: Here is the month : SEPT
    and      TRUNC(Eff_date) =:YEAR     ?? PARAMETER: Here  is the Year : 2005I need to concatenate parameters MONTH and YEAR in one and then
    display records for that month.
    How can I write the SQL Query to concatenate MONTH and YEAR and
    TRUNCATE the column eff_date?
    Please help.

    Env : ORACLE REPORTS 9I
    I am passing 3 parameters to the report:
    Parameters are of type CHAR
    Report Parameters
    Year / Month :   2005 / AUG
    Effective Date :
    The colunm in table is eff_date
    eff_date
    01/08/2005
    02/08/2005
    03/08/2005
    15/09/2005
    17/09/2005
    18/09/2005
    29/09/2005The problem is:
    1)If I dont enter anything,I just get displayed 2 record for the above.
    It should display all records rather than 2.
    2)If I enter Effective date as 01-AUG-2005,no records are displayed.
    This is my code:
    Select col1,col2
    from   TableA
    where ( TRUNC(ch.eff_date) = nvl (:E_DATE, TRUNC(ch.eff_date) ) 
    AND     TRUNC(ch.eff_date, 'MONTH') = nvl (TO_DATE(:YR||:MTH,                                                                                                          'yyyymon') ,
                                               TRUNC(ch.eff_date) )
          )Shud i change the AND to OR?

  • How to get currect date by using month and year

    hai,
    By using month like 'Jul' and year like 2007 i want to get full date like 01/06/2007(format).Please give me query for this?My fields for month and year are respectively vr_mnth(varchar) and in_year(number)

    i used to_date function but it accepts only one string .if i give like this
    to_date(vr_mnth,in_year,'dd/mm/yy') it will gives me syntax error.
    If i give like this vr_mtnh='Jan'
    to_date(vr_mtnh,'Mon') it will give output
    01/01/2008 it shows me current year
    if i choose from table wich is strored with month-'Jul' and year=2006 it shows me
    01/07/2008 only .It doesn't shows me that 2006 year
    If i give in_year in to_date it gives me that currect year.
    Ex:to_date(in_year,'YY')..............>01/01/2006
    Individually to_date function works fine but i want to club both to get accurate date format of specified month and year.Is there any function for that in sql to get 01/07/2006?

  • I have been using Itunes on my HP laptop for 12 months and over the past month have not been able to access the Itunes store or any of the Itunes Help type menu's. When in Itunes I click on the Store icon and the top middle box gets to Half way. Pls help

    I  have been using Itunes on my HP laptop for 12 months and over the past month have not been able to access the Itunes store or any of the Itunes Help type menu's. When in Itunes I click on the Store icon and the top middle box gets to Half way. Pls help

    I had the same tried loads of fixes
    saw this on the community from whatheck
    In windows 7 click on your start menu, go to the accessories, right click on the command icon and choose "run as administrator"
    Once it opens type the following command...
    netsh winsock reset
    Hit enter and it should say something like winsock reset successful now reboot your computer
    IT WORKED....... cleared all the "action2 on the CPU and loads IStore perfectly

  • Animation - Can I use an expression (event based) to display an Animation? - New User

    I am bench testing my application with a DL05. This has been a great way to learn the Lookout application. Ex: PB, high/low bit conditions representing the same PB's color and text state (PB object with no text description, just color background and with it use a logical expression with text and transparent background). Also, multi state text and background color representation using only logical expressions. This way I do not have to develop bitmap graphics (only have the coloring book MSPaint) for text with variable background color.
    Animations: I need the animation (condensor fanpic1 - which I have rotating with a green background - 1 row 4 columns ) to appear upon a Y2 high bit and not visible upon a low. Also, on the Y2 low bit (condensor fanpic2 - which is not rotating with a gray background - using multistate low = condensor fanpic2 high = null graphic) visible. I have tried several scenarios in trying to make animation (condensor fanpic1) not visible/transparent. No succes. It (condensor fanpic1) is always present regardless of high/low state.
    I have tested live communications between PB's, pumps, texts, and variable numeric diplays and inputs to various dicrete and Vmemory addresses. K-Sequence protocol. Working well.
    Please help,
    Brad

    Yes. So obvious and simple, duh! With your help. The visible tab works great for the animation.
    I should have seen that. Here is probably another obvious one for you concerning the same concept. I want the non rotating (condensor_fanpic2) to be visible when Y2 is low.
    I first tried with a Display Multistate if: PLC_RS232.Y2=0 and (graphic space) = condensor_fanpic2; Else ifLC_RS232.Y2=0 and (graphic space) = null. It remains not visible, regardless.
    A Logical Expression however works: PLC_RS232.Y2 ON = null and OFF = condensor_fanpic2 visiblility and non-visibilty works great. Opposite state with my animation visibility and non-visibility.
    Why won't a Display Multistate described above work with just 2 discrete states assigned?
    Brad

  • Using Airport Express to listen DVD via Front Row and Optical Out

    I want to find out if this is possible:
    I currently have Macbook Black Core 2 Duo. I enjoy watching DVDs using Front Row. The DVI video cable goes to the projector which is at the back of my room. Since the Macbook is close to the projector, I have to run optical audio cable to the 5.1 Dolby Digital home theater sound system at the front of my room.
    I am interested in the AirPort Express because it can play iTunes wirelessly and use optical output to hook up the stereo system.
    The question I want to know is if it's possible to connect Airport Express optical output into my Dobly Digital sound system so I can watch and listen DVD movies via Front Row? If not, any other alternatives? When searching through topics, it seems the users said Rogue Amoeba has a lag issue. Even I am not sure it can do optical output capabilites. Any thoughts. Thanks!
      Mac OS X (10.3.9)  

    KonradL, Welcome to the discussion area!
    To stream non-iTunes music to the AirPort Express (AX) you need Airfoil.

  • Using Airport Express as internet connection for one Mac and one PC

    Will probably be judged a complete dork for this question. I have successfully set up my Imac G5 to run an internet connection through an Airport express. My partner runs a PC (Windows XP) and I want to connect this too. Have installed a USB wireless card on the PC, and installed Airport Utility, but it just won't find the Airport Express - it will however find the Imac with something like 96% signal strength. So I set up a network on the Mac and have successfully linked into it with the PC, but it soon comes up with a connectivity problem that will not allow internet browsing. So two questions - can I connect two computers to the Airport Express at once for internet browsing, or do I have to do it through linking the PC to a wireless network? If the latter is the route - any ideas on what the connectivity issue will be? Help!

    No, not if the AirPort Express "joins" the wireless network.
    No, I do not want to join a network.
    It is possible to have the AirPort Express "create" a separate wireless network that would not have access to the Internet, but if you did this, you would need to log off of your normal network....(losing your Internet connection) and then log onto the AirPort Express network when you wanted to listen to AirPlay.
    Then, when you wanted to have Internet access, you would have to log off of the AirPort Express network and log back onto your normal wireless network.
    Ok, I understand that it is not possible to use airport express only for sound streaming while having an Internet connection at the same time. Airport express does need to join a network if I want sound streaming next an Internet connection. I wanted airport express not to get into way of my Internet connection because in this case the sound streaming messes up sometimes. When I configure airport express only as a sound output, the problems I encounter fade away but then I cannot access to the Internet. Anyhow thanks a lot for the answer.   

  • Using htmlb:dateNavigator to only display month and year

    Hi all,
    I would like to use the dateNavigator to allow the user to choose a month and a year BUT NOT a day. Does anyone know if this is possible? Would it make sense to use htmlb:dateNavigator for this or should I use some other means?
    Thanks a lot for your help.
    Best Regards
    Jens

    I am not sure whether you can use dateNavigator for this case , similar case we have used htmlb:dropdownListBox
    <htmlb:dropdownListBox id                = "period"
                                             nameOfKeyColumn   = "NAME"
                                             nameOfValueColumn = "VALUE"
                                             table             = "<%= tab1 %>"
                                             onSelect          = "DDLB1Event"
                                             selection         = "<%= period %>"
                                             width             = "110"
                                             disabled          = "<%= dd_disable %>" />
    ta1 is of type TIHTTPNVP which we populated with year and month.
    Regards
    Raja

Maybe you are looking for

  • Batch importing Word files into separate InDesign files

    Hi, I have what I though would be a fairly common question, but I can't seem to find any information about it in this forum or on the web. I have a folder of Word files (over 100, which is why I don't want to do this manually) and one InDesign CS4 fi

  • How to add new value in operator in search parameter in web ui

    Hi, I have a requirement to add values (equal ,not equal ) in operator drop-down field of search parameter in search of web ui page. Can someone guide me to proceed on this. Thanks Viren

  • IPhone Stocks app is stuck in edit stocks mode.

    Any idea? I click on the Done button, but nothing happens.

  • Chromium weird font rendering

    Hey, i was wondering if anyone else has the same problem with chromium font rendering, i already tried setting the .Xresources as stated on wiki, but it didnt seem to take effect. I also tried the fonts.conf from this thread: https://bbs.archlinux.or

  • Accessing Citadel 5 or Citadel 4 through ODBC in DIAdem

    Hi, I am trying to use the Citadel 5 and Citadel 4 Database. I am making use of ODBC. Can anyone tell me how can I connect to this Database in DIAdem and apply query(Insert, select queries) so that I can load the data from Citadel to the Diadem Data