Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to make the report to display week wise data Expand / Collapse
Author
Message
Posted Friday, April 11, 2014 4:16 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, April 23, 2014 3:13 AM
Points: 26, Visits: 41
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"
Post #1560801
Posted Friday, April 11, 2014 4:22 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, December 8, 2014 6:02 AM
Points: 470, Visits: 484
What all steps have you tried till now ? Where are you facing problem grouping it @ report level or @ Script level ?
Post #1560804
Posted Friday, April 11, 2014 4:33 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, April 23, 2014 3:13 AM
Points: 26, Visits: 41
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
Post #1560809
Posted Friday, April 11, 2014 4:51 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 12:04 PM
Points: 328, Visits: 3,624
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.
Post #1560817
Posted Thursday, April 17, 2014 5:33 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, April 23, 2014 3:13 AM
Points: 26, Visits: 41
Thanks for ur reply.

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

Post #1562613
Posted Sunday, April 20, 2014 12:26 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 12:44 AM
Points: 927, Visits: 5,899
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!
Post #1563312
Posted Sunday, April 20, 2014 9:02 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 7:27 AM
Points: 35,769, Visits: 32,437
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1563384
Posted Monday, April 21, 2014 9:02 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 10:48 AM
Points: 1,170, Visits: 2,545
My company does not use Date Dimension or Calendar tables, our solution to this kind of thing is similar to aar.mba.

select
Post #1563512
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse