.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

AGGREGATE over a time period: how to behave like a distinct count ? (aggregate on the full period an

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :Sql Server

I would like to compute a measure "MyMeasure" over the last 12 months :

Aggregate({[Event DATE].[Calendar].CurrentMember.Lag(11):[Event DATE].[Calendar].CurrentMember},[Measures].[MyMeasure])

MyMeasure is not a distinct count, so the results returned is the SUM of the distinct count performed on each month over the last 12 month.

What I would like to have is the distinct count over a full year (all months taken together).

For example, suppose that MyMeasure is a simple measure that always returns 1.

The aggregation returns 12 (1 for each month then SUM). I would like it to return 1 (measure on the whole period).

Can somebody help me that's really a very big issue I have to fix !


View Complete Post

More Related Resource Links

Returning Customer Count of all categories in each time period



Lets say I have the following Table:

CustomerNumber | Date | MovieCategory
1 |2010-01-01|A
1 |2010-02-01|A
1 |2010-03-01|A
1 |2010-04-01|A
1 |2010-05-01|A
1 |2010-06-01|D
1 |2010-07-01|A
2 |2010-01-01|A
2 |2010-02-01|A
2 |2010-03-01|D
2 |2010-04-01|D
2 |2010-05-01|D
2 |2010-06-01|C
2 |2010-07-01|C
3 |2010-01-01|B
3 |2010-02-01|B
3 |2010-03-01|B
3 |2010-04-01|C
3 |2010-05-01|C

What I want to do is count the number of customers for each movie type in each date. Now I started with the following simple query

Select Date, MovieCategory, Count(CustomerNumber)
From AboveTable
Group By Date, MovieCategory
Order by Date, MovieCategory

which would be okay, but if no customer has a MovieCategory of say 'B' on a particular date then the results of the above query won't return a row that has

Date| B| 0     (date here could be any date).


which is really what I need. Is there a good way to

The semaphore time-out period has expired

Hi, We have a job that does use linked server to copy some data from a MS SQL 2000 database and insert it into a database which runs in MS SQL Server 2005.This job is configured in the 2005 server. Offlate we started encountering the error OLE DB provider "SQLNCLI" for linked server "RSSDR" returned message "Communication link failure". [SQLSTATE 01000] Error Number::121 Error Message::TCP Provider: The semaphore time-out period has expired. Initially thought its a network issue but network team have confirmed there were no network issue at the specified time.Is it something related to network adapters,card or some other firware. Any help would be highly appreciated. Best Regards, Zainu    

MDX Query Measure with time period

Hi! How to set up the period in MDX? I need the measure what would be seted up by default 4, 29… days from today. For axample Amount from current day (02.09.2010) till 4 days from today is 06.09.2010. As Result I have to get a report: Buy form Vendor Amount today 02.09.2010 Amount +4days 02-06.09.2010 Amount +29days 02.09-30.09.2010 A 10000 250000 333333 B 150000 222222 555555 C 666666 444444 1222222 Sincerely, Milena

SPD to escalate workflows over a period of time

Hello,   I am hoping that you can help me, I have designed an InfoPath form that I am using for an expenses approval, but I would like to set it so if the approver has an Out of Office, the workflow is submitted to a different user. And if the workflow exceeds a specific time range then the workflow is escalated.   I am using SPD to create these workflows, rather than the in built MOSS workflows.   You're help, as always, is greatly appreciated.   Kind Regards, Dayna

How to concatenate measures over time period?



For an external tool I have to prepare Sales ([Measures].[Sales]) figures for the last 5 months like this: 12345|12343|21423|12344|12343. So basically, I need one measure that displays these values concatenated. How can I create this? (In my MDX query I would have this measure on columns and i.e. another dimension like country on rows).



Sharepoint site getting time period expired



I am having a file which is contain 70,000 data. i try to upload this file into sql server table using front end sharepoint site.i am getting time out period expired error.

But i have added connection timeout=100000 property in connection string still i am facing the same problem

So please help me to solve this issue



NetworkStream ReadTimeOut doesn't wait for the time out period



I am using the TCPClient and the NetworkStream classes to establish a TCP connection and read the data from the network.
The NetworkStream object is set with a time out of 15 sec. The intent is, if the stream can't see any data from the network within 15 sec,
it will throw an exception and return. Something like myStream.ReadTimeOut = 15000. I set this time out once in the beginning just after the TCP connection  and the NetworkStream are created.

Though majority of the times (70%) it behaves nice and waits for the time out period to expire before throwing the System.IOException,
other 30% of the times, it just doesn't wait 15 sec before throwing the exception. It doesn't even wait for 2-3 milliseconds before throwing the exception.

I verified this using another tool, wireshark to time and detect the traffic.

Is the NetworkStream object doing some kind of optimization? Or do I have to do anything special to make it to wait for 15 sec?


Tech Crawler


Count people quantity for date period



I have following table:

id          staff_id                store_No                start_date                 end_date

1              st1                          s1                     09/25/2010                10/5/2010      

2              st1                          s2                     10/06/2010       

Aggregate (count) function that produces a different result to what is expected.

Hi Folks
I have an aggregate transformation, that runs a count on a column.  The  column  has 23 rows  with dates and a further 2 rows that have no date information. When I run a count function on the column, it returns a count of 25.  My hypothesis is that  this is linked to the 2 rows are treated as being  BLANK as opposed to being NULL (I understand the COUNT function will not count rows that have null values).

I have two questions
1) How do test this hypothesis that he difference is due to a blank vs null issue and then more importantly
2) How to I resolve the issue so that the 2 "empty" rows are not counted?

Many thanks


SQL Server Query request for start and end period of time


Hi all

I have event table where I need to select records between days. my statements look like

  CONVERT(char(8),Event_Table.Event_time,112) BETWEEN 'request start date' AND 'request end date'

The Event_time is DateTime format.


Now everything look fine except from if I need the statement to request the date between as Date_start and Date_End any time it run. The idea is to request a for start and end period of date any time the scrpt run. the script will be run as DOS batch file. 

Built-in Functions - Aggregate Functions

Aggregate functions return a single value summarizing a given data set. All aggregate functions are deterministic. NOTE: AVG, SUM, STDEV, STDEVP, VAR and VARP functions cannot operate on BIT data types; they can operate on all other numeric data types.

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is no



 I keep getting the following error. I also added time out parameter in the connection stirng and it still did not help. Has any one faced similar issues.

Thanks in adavance.

Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.]

Creating .NET Assemblies That Aggregate Data from Multiple External Systems for Business Connectivit

This article describes a quick, four-step process for creating a .NET assembly that BCS can use to retrieve external data for SharePoint Server 2010 by using Visual Studio 2010.

Dynamic Dimension with Aggregate Values

Hi, I have an specific requirement to make the measure value as an dimension. Let me explain my problem in brief. I have a fact table with dimensions like Time, Products etc and having single fact table with two measures. I have to create a calculated measure which shows the average of Measure 1 (here used calculated measure because there are couple of other calculations involved). And other two calculated measures. when I drill down with Products dimension for Calculate measure 1, it shows the average value for each products. Now, I want this calculated measure values (includes Product dimesnion drill down) as a Dimension and based on this value, I need to show the value of other two measures. For example: when the dimension products is used for drill down the values displayed will be like this and in this I need CM1 to be another dimension Products CM1 CM2 CM3 P1 0.10% 20 1 P2 0.20% 40 2 P3 0.30% 80 3 P4 0.40% 70 4 P5 0.50% 30 5 P6 0.60% 110 6 P7 0.70% 120 7 P8 0.80% 130 8 P9 0.90% 86 9 P10 1.00% 65 10 when CM1 is used as a dimension it should show the value like this CM1 CM2 CM3 0.10% 20 1 0.20% 40 2 0.30% 80 3 0.40% 70 4 0.50% 30 5 0.60% 110 6 0.70% 120 7 0.80% 130 8 0.90% 86 9 1.00% 65 10 How can we create the dynamic dimension with the aggregated values? Any assistance will be greatly apprec

About the Aggregate Function MIN

Hi all, I am using the select statement with MAX(id), MIN(id), COUNT(*) of a very big table and it is returning me the value in less than a second. But surprisingly if i am using aggregate function MIN(id) in a seperate select statement it is taking upto 90 Seconds. Here are the 2 statements I am running SELECT MAX(ID),MIN(ID),COUNT(*) FROM A TABLE  -- Time consuming for this:  less than a Second. SELECT MIN(ID)FROM A TABLE  -- Time consuming for this:  Upto 90 Seconds. Please clarify how it work internally when we call the select statement with Aggregate functions?  chinna

Can I safely perform full backups without breaking log shipping? Can I do point in time restores if

I'm building a system using SQL Server 2008. I have log shipping set up across our WAN, and that's working fine. I need to perform local backups on the primary server so that I'm not relying on the (slow) WAN if it needs to be recovered from a server crash. Ideally, it would be nice to be able to perform point in time restores. I understand that I can use the transaction log backups, created for log shipping, to restore from. But I still need a full backup to start the restore from - and there seems to be some confusion regarding whether or not performing a regular full backup on the primary server will affect log shipping. Even on these forums, conflicting advice has been given, with some people saying it's fine as long as you don't do transaction log backups, and others saying you must run COPY ONLY backups (though they were talking about Server 2005). From what I understand, you can't do point in time if you use copy-only backups. I'm getting the impression that this used to be a problem under 2005, but under 2008 you can safely perform full backups while log shipping is running. Can anyone confirm my understanding before I make a career-altering error? :)

Timeout error - The timeout period elapsed prior to completion

Hi, I'm using ASP.NET 3.5 (c#) with SQL Server 2008 server. Recently, I started getting error "Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.". After looking at forums for solutions, I added the below common code to my application. protected DbCommand CreateCommand() { SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandTimeout = 600; // 10 minutes return sqlCommand; } However, intermittently, I'm still getting the timeout error. I added the logging to see where error is occuring. And found that before executing one of the query, it is giving this error. Now, my assumption is that I should have received this error after runnign query for 600 seconds (10 minutes) since I set it in the above function. But the timeout error is occuring instantaneously within 1 second itself. In the log, I printed one line above & after the query to identify how much time it would take. Surprisingly, the log says that 9:00 AM "Before query execution" & at 9:01 AM "timeout expired...." I would really appreciate if some one can help me out here! Thanks!
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend