Showing posts with label applications. Show all posts
Showing posts with label applications. Show all posts

Tuesday, March 27, 2012

Computing change from first sales by employee

I'll use AdventureWorks to frame my question, as then I can extend any suggestions to the possible applications I need.

I want to create a calculation which finds the change of each employee's monthly sales amount from their first month's sales.

e.g. for each month it will show how their sales for that month differs from the first month they ever made a sale.

What I'm struggling with is that one employee may have made their first sale in 2001, while another made their first sale in 20003. I'd like to be able to show how each employee's sales change relative to their first month, i.e. in month 2, month 3, etc.

I am thinking that I will need to define a new calculated measure which is the number of months elapsed for each employee since their first sale and then define a calculation for their deltas per month, but I'm not sure.

I've read up on OpeningPeriod() and the "Opening Period Balance" template, but I'm stuck. Using AS 2005.

Thanks for any suggestions.

-Leif Kirschenbaum

Leif,

Here is an example that I think will give you what you are looking for. I included a measure called "First Months Sales" which is just to show how the calculation is working and is not really needed for the end result.

HTH,

Steve

WITH

MEMBER [Date].[Calendar].[First Month With Sales]

AS

Filter([Date].[Calendar].[Month].Members, [Measures].[Reseller Sales Amount] > 0)(0)

MEMBER [Measures].[First Months Sales]

AS

([Date].[Calendar].[First Month With Sales],

[Measures].[Reseller Sales Amount]),

FORMAT_STRING = "currency"

MEMBER [Measures].[Difference]

AS

IIF(Exists({[Date].[Calendar].CurrentMember},{Filter([Date].[Calendar].[Month].Members, [Measures].[Reseller Sales Amount] > 0)(0).Lead(1):NULL}).Count = 1 AND

[Measures].[Reseller Sales Amount] > 0,

[Measures].[Reseller Sales Amount] - ([Date].[Calendar].[First Month With Sales],[Measures].[Reseller Sales Amount]),

NULL),

FORMAT_STRING = "currency"

SELECT

{[Date].[Calendar].[Month].Members} ON COLUMNS,

{[Reseller].[Reseller].[Bike Rims Company],

[Reseller].[Reseller].[Certified Sports Supply]} *

{[Measures].[Reseller Sales Amount],

[Measures].[First Months Sales],

[Measures].[Difference]} ON ROWS

FROM

[Adventure Works]

|||Great!
Thanks.
I do need one other thing, I need a dimension which counts the months from the first month for each employee. Right now in the browser when I drag Employee hierarchy to the rows field and Calendar to the columns field the difference for each employee starts in a different month. It would be useful to be able to drag "Months of Employment" to the columns field.
Would I do:

CREATE MEMBER CURRENTCUBE.[Date].[Calendar].[Months of Employment]
AS
[Date].[Calendar].[Month] - [Date].[Calendar].[First Month With Sales],
FORMAT_STRING = "Standard",
NON_EMPTY_BEHAVIOR = { [Reseller Sales-Sales Amount] },
VISIBLE = 1 ;

That doesn't work.

CREATE MEMBER CURRENTCUBE.[Measures].[Months of Employment]

AS

[Date].[Calendar].[Month] - [Date].[Calendar].[First Month With Sales],

FORMAT_STRING = "Standard",

NON_EMPTY_BEHAVIOR = { [Reseller Sales-Sales Amount] },

VISIBLE = 1 ;


also doesn't work, as I can't drag "Months of Employment" to the columns field.|||

Leif,

Try the following:

MEMBER [Measures].[Months of Employment]

AS

IIF(Exists({[Date].[Calendar].CurrentMember},{Filter([Date].[Calendar].[Month].Members, [Measures].[Reseller Sales Amount] > 0)(0).Lead(1):NULL}).Count = 1,

{Filter([Date].[Calendar].[Month].Members, [Measures].[Reseller Sales Amount] > 0)(0):[Date].[Calendar].CurrentMember}.Count - 1,

NULL),

FORMAT_STRING = "#,#"

Tuesday, February 14, 2012

Compatibility of MSDE with .NEt

Hai frnds,

Can i use MSDE for my .net applications instead of SQl server ?

Yes.|||

Can u sugget some good documents regarding MSDE compatibility with .NET

Applications

|||

There's nothing much to say. MSDE is basically the same thing as SQL Server execept some performance limitations and missing components (no graphical interface tools, no analysis services etc). Other than that it supports exactly the same SQL syntax and data types, views, triggers etc like SQL Server 2000 and for connection you use the same classes (System.Data.SqlClient) and connection strings.

You may also want to check SQL Server 2005 Express Edition which is also free and works with .NET and replaces MSDE. See http://www.microsoft.com/sql/editions/express/default.mspx

http://www.microsoft.com/sql/editions/express/upgrade.mspx

http://www.microsoft.com/sql/editions/express/features.mspx

Sunday, February 12, 2012

Compatibility between SQL2000 and SQL2005

Will my old applications with standard T-SQL code work againt the new
SQL2005 without modifications ?
KayHi
It depends. Mostly yes, but if you are using any syntax that Microsoft has
been warning will be depricated, or any undocumented functions, no.
You will have to test.
Regards
Mike
"Kay-Christian Hansen" wrote:

> Will my old applications with standard T-SQL code work againt the new
> SQL2005 without modifications ?
> Kay
>
>|||If there is any breaking bits, MS will issue a document before release. Thus
far, I have seen nothing that is not backward compatible in T-SQL. If you
follow good standards, you should not have any problems. There are new
additions to T-SQL in SQL 2005, however, that you might want to move to for
perf, etc.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
****************************************
*******
Think outside the box!
****************************************
*******
"Kay-Christian Hansen" <Kay@.Tempus.no> wrote in message
news:OhbU4zbOFHA.2252@.TK2MSFTNGP15.phx.gbl...
> Will my old applications with standard T-SQL code work againt the new
> SQL2005 without modifications ?
> Kay
>|||There are a few changes, for example with the new schema getup,
INFORMATION_SCHEMA.SCHEMATA doesn't work like it currently does in 2000.
There are also some very forceful changes to non-ansi outer joins (*=, =*).
For the most part, backward compatibility is pristine, but there are several
other things going forward that, while you don't have to deal with it right
away, you should definitely visit before the next version after 2005.
You really should be asking this kind of question in the SQL Server 2005
newsgroups.
http://www.aspfaq.com/sql2005/show.asp?id=1
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Kay-Christian Hansen" <Kay@.Tempus.no> wrote in message
news:OhbU4zbOFHA.2252@.TK2MSFTNGP15.phx.gbl...
> Will my old applications with standard T-SQL code work againt the new
> SQL2005 without modifications ?
> Kay
>