How to make the report to display week wise data

  • Hi,

    I want my report to fetch data from Financial year starting to till date.

    i.e Apr 2013 to till date.

    till date means Today() minus 8 days and @Fromdate includes last week of march also

    i.e Mar 29 2013 to Apr 4 2013 - this week data will also be included

    So data from Mar 29 2013 - Apr 4 2013 to today() minus 8 days need to be displayed

    How to fetch data for this.

    Pls advise.The column corresponding to this looks like "2013-11-01 ~~ 2013 - 11- 07"

  • What all steps have you tried till now ? Where are you facing problem grouping it @ report level or @ Script level ?

  • I kept @odate as today() - 8days

    and @Fromdate as "= Iif(Month(today())>04, "04/01/"&Year(Today()),Iif(Month(today())<= 04, "04/01/"&(Year(Today())-1),1))"

    i wrote this query to fetch from april of last year.

    i.e if i run today (year is 2014).It should automatically fetch from last year (april 2013)

    i don't know how to proceed to for weekwise

  • With reporting requirements of this type, it's standard to use a Date Dimension.

    This makes your code much less complex - and therefore more maintainable, it's orders of magnitude easier when reporting periods change (or even just the format of a reporting period description), you run one update against the values in the column rather than have to track down and update te complicated bits of code scattered through your codebase. It's also more efficient as you're simply adding a join rather than doing expensive calculations

    I'm a DBA.
    I'm not paid to solve problems. I'm paid to prevent them.

  • Thanks for ur reply.

    But what update I should run and how to create dimension.

  • If you're using a normal database and not an SSAS cube, then you can use a Calendar table. Here's the article on it: http://www.sqlservercentral.com/articles/T-SQL/70482/

    Basically, the Calendar table has a series of dates, and a bunch of other derived columns (hey, they're static data you can filter on!) you just join from your table to the date key in the Calendar table and then away you go!

  • pietlinden (4/20/2014)


    If you're using a normal database and not an SSAS cube, then you can use a Calendar table. Here's the article on it: http://www.sqlservercentral.com/articles/T-SQL/70482/

    Basically, the Calendar table has a series of dates, and a bunch of other derived columns (hey, they're static data you can filter on!) you just join from your table to the date key in the Calendar table and then away you go!

    "It Depends". I find that some simple formulas are, many times, much faster, shorter, and easier to write than using Calendar Tables.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • My company does not use Date Dimension or Calendar tables, our solution to this kind of thing is similar to aar.mba.

    select

Viewing 8 posts - 1 through 7 (of 7 total)

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