SSRS 2008 R2 Dev question

  • How to get the average and total amount of last three months or quater based on the paramter @runyear

    example I have runyear =2011 IN SSRS

    i need avg on "PAmount column " for that quater(three months) grouped on cname and LOCdesc

    I have a DATA which looks like this

    Cname | LOC desc | PMonth | PAmt

    A DENT 2011-03-01 300

    A DENT 2011-06-01 600

    B DENT 2011-03-01 800

    C MED 2011-06-01 700

    C MED 2011-03-01 300

    Needed : Based on given Year(as parameter) 2011 Need totals in Quaters like

    Cname | LOC desc | PMonth | PAmt

    A DENT 2011-03-01 300

    QUATER 1 TOTAL : 300

    B DENT 2011-03-01 800

    Quater 1 Total :800

    C MED 2011-03-01 300

    Quater 1 Total :300

    A DENT 2011-06-01 600

    Quater 2 Total :600

    C MED 2011-06-01 700

    Quater 2 Total :700

    QUATER2 TOTAL : 700

    thanks,

    Komal

  • Make a calendar table. Here's mine : http://www.sqlservercentral.com/Forums/Attachment8839.aspx

    Then SELECT * FROM dbo.Calendar WHERE Y = @Year

    will give you all the dates for that year. You'll also notice all the groups you can possibly ever want.

    Left join the calendar to your final dataset and then group BY whatever you need.

    I usually do this for the columns GROUP BY Year, then Quarter then month (3 levels). SSRS makes the final sum for this.

  • I am getting the parameter values from the Store proc for @runyear and also data!!!!

  • I don't understand your problem with that!

  • Hi...I see the table you sent have month names in diff language ?? Can I get the one with English please???

    Or It maight not make difference???

    Thanks,

    komal

  • Just use datename and update the whole table.

    You'll need to set the correct us holidays as well. I've used canadian holidays here so some of them are different.

  • Updated the table.But still did not get how to merge the dataset (created from storeproc) with the calender table? to get as one dataset in ssrs???

    On what column to join???

  • Join on dt (date).

  • Hey thank you....I got it by quaterly.Now I need to get average and totals of the past three months "Pamt" for each "cname" across all " LOCDESC".This is Different report.

  • where dt BETWEEN DATEADD(M, -3, GETDATE()) AND GETDATE() (or use @endate if the user needs this as a parameter....

  • I dont want to change anything to storeproc , but add as a seperate column as average : to display average for past three months( from current month) and also totals for past three months ( from current month ) ...just add as an expression??

  • sure add a new column similar to this :

    IIF(date > whatever, Value, 0)

  • Hi ...can you please be more specific....? i did not understand??

  • In the dataset and a new column. Hit expression. Then put the IIF()

  • Hey...I know how to add expressions....but did not understand your iff condition!!

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic. Login to reply