I would like to modify the Team Foundation Server built-in MS Agile template reports to exclude weekends.
For example, here is the dsWorkItemHistory dataset for the Remaining Work report:
WITH
MEMBER [Measures].[Date Key] AS
[Date].[Date].CurrentMember.UniqueName
SELECT
{
[Measures].[Date Key],
[Measures].[Cumulative Count]
} ON COLUMNS,
(
[Work Item].[System_State].[System_State],
(StrToMember(#StartDateParam):StrToMember(#EndDateParam))
)
ON ROWS
FROM [Team System]
WHERE
(
STRTOMEMBER("[Team Project].[Team Project].["+#Project+"]"),
STRTOSET(#IterationParam),
STRTOSET(#AreaParam),
STRTOSET(#WorkItemTypeParam)
)
I am totally unfamiliar with MDX. Any pointers toward customizing the data returned to exclude weekends is appreciated.
Use the datepart function with the dw part to exclude Saturday and Sunday.
SYNTAX: DATEPART ( datepart , date )
in this case datepart = dw or weekday,
and date is the date field in your query.
Related
I have a report returning teams, case IDs and dates. Each team has multiple cases and each case belongs to only one team. Each case has multiple dates and each date belongs to only one case.
I need to build a summary table that lists all the teams and for each one counts the number of cases for which the latest date was in timescale. For a date to be in timescale it must be within 42 days of the previous date for the same case.
E.g. The two latest dates for Case#1 are 01/08/2021 and 01/09/2021, so this should be counted for the governing team. The two latest dates for Case#2 are 01/07/2021 and 01/09/2021 so this case should NOT be counted for the governing team.
What formula will perform this count?
I can't seem to get anything other than null or MULTIVALUE results.
If you show team in your block :
Updated answer
start date
=If(
Count(
[date]
In([case]; [date])
)In([case]) <= 1;
[case start date];
Previous([date])
)
end date
=If(
IsNull([date]);
CurrentDate();
[date]
)
Days since previous update
=If(
[case] = Previous([case])
And ([date]=Max([date]) In ([case]));
DaysBetween([start date]; [end date])
)
cases in timescale
=Sum(
If([Days since previous update] <= 42; 1; 0)
In([team]; [case]; [date])
)
I have a table that is set up like
SELECT [EntryDate] --Date
,[StoreId] --Nvarchar
,[PassFailElement] --Int, 1 or 0
And the SSRS report is set up for the user to input #StartDate and #EndDate to bookend the [EntryDate]s they want to see.
Is there a way to create a line graph that shows the values for [PassFailElement] from #StartDate to #EndDate as the first series, DateAdd(DateInterval.Year,-1,#StartDate) to DateAdd(DateInterval.Year,-1,#EndDate) for the second series, and then two years back for the third series?
I'm sure there are a million more elegant ways to do this but here is how I might approach it...
The following is based on the Microsoft supplied NorthWind database so you can recreate it if you really want to...
I've set the actual start and end date values in here but you can comment out the first few lines and then your SSRS parameters will be applied.
So to start with a took the orders table as it had some dates in and joined to some basic order data just so I could see the results looked OK, most of the columns are not used.
My dataset looks like this...
SET DATEFORMAT YMD
DECLARE #startDate date = '1998/04/01'
DECLARE #endDate date = '1998/07/30'
SELECT
e.EmployeeID, e.FirstName, e.LastName, e.Title
, o.OrderID, o.OrderDate
, c.CustomerID, c.CompanyName
, CASE
WHEN (OrderDate between #startDate and #endDate ) THEN 'This Year'
WHEN (OrderDate between dateadd(YYYY,-1,#startDate) and dateadd(YYYY,-1,#endDate )) THEN 'Last Year'
WHEN (OrderDate between dateadd(YYYY,-2,#startDate) and dateadd(YYYY,-2,#endDate )) THEN '2 Years ago'
END as YearGroup
, MONTH(OrderDate) AS OrderMonth
, Day(OrderDate) AS OrderDay
FROM Employees e
join Orders o on e.EmployeeID = o.EmployeeID
join Customers c on o.CustomerID = c.CustomerID
WHERE
(OrderDate between #startDate and #endDate ) OR
(OrderDate between dateadd(YYYY,-1,#startDate) and dateadd(YYYY,-1,#endDate )) OR
(OrderDate between dateadd(YYYY,-2,#startDate) and dateadd(YYYY,-2,#endDate ))
The Case statement in the SELECT clause checks to see if the dates fall into one of three groups, either
between the start and end dates supplied
between the same date range but minus a year
between the same date range but minus two years
The computed OrderMonth and OrderDay are there as I assume you will want to 'stack' the lines so say, 1 June, across all three groups is in the same horizontal position on the chart. ** See notes later for changing this.
The WHERE clause does similar tests to make sure we only return data from the ranges we need.
All I did them was simply add a line chart and set
the Series Groups to the [YearGroup] field
the [OrderMonth] and [OrderDay] to the CategoryGroup
and (for no other reason than I didn't have much else to display) I used the sum of OrderID as the values.
** if you want to represent the time range as one continuous time, then remove the OrderMonth and OrderDay from the category groups and replace with OrderDate
The resulting chart looked awful but that was just down to the data.
I would create a couple of Calculated Fields in your dataset to break up the data and add them to the chart.
The first would be a field that determines which year the data is in - Current, Previous or the Prior. Maybe just 0, 1 or 2? This field would be used as your chart series. Call it ENTRY_YEAR.
The second would be a date field with the years all set to the current year. You could just add the integer from the first field. This will normalize all your data to a single year timeline. You won't actually use the year - that's just to separate the data at the year break.
=DATEADD("y", ENTRY_YEAR, Fields!EntryDate.Value)
I have an SSRS report which gets filtered with the following expression:
="{[Claim Cheque].[Cheque Date].&[" + format(Parameters!StartDate.Value, "yyyy-MM-dd") + "T00:00:00]:[Claim Cheque].[Cheque Date].&[" + format(Parameters!EndDate.Value, "yyyy-MM-dd") + "T00:00:00]}"
which works fine. My problem is I don't have cheques everyday and this makes the query return no results. As an example I'm choosing the date range from 1st to 20th of November. I have cheques in 14th and 15th but NOT 20th. I will miss 14th and 15th results in my report this way.
I know how to force the parameters to get only existing values in the cube. but I need to be able to select all dates. Is there any other way to make this expression return desired results?
Any help is appreciated.
It looks to me like you have a separate date dimension just for [Cheque Date], rather than linking back to a fully populated master date dimension. Take a look at the way Order Date and Ship Date dimensions are done in the AdventureWorks sample. They are explained nicely here: Role-playing dimensions
I was able to run MDX queries like yours against that data, where there were no transactions on the start and end dates of the range:
Select
[Measures].[Order Count] on 0,
[Sales Channel].&[Reseller] on 1
From [Adventure Works]
Where {[Ship Date].[Fiscal].[Date].&[20060701]:[Ship Date].[Fiscal].[Date].&[20060710]}
and
Select
[Measures].[Order Count] on 0,
([Sales Channel].&[Reseller],
{[Ship Date].[Fiscal].[Date].&[20060701]:[Ship Date].[Fiscal].[Date].&[20060710]}) on 1
From [Adventure Works]
How can I write an MDX statement or query that selects the clients who paid last month but have not paid this(Current Month) month?. I have a data cube designed and deployed on Microsoft SQL Server Analysis Services R 2. I have a customer dimensions and a fact table.
Please help.
I assume you have a [Time] dimension, and a measure that contains a value if the client has paid. I think the Filter() function will help you reduce a set of all clients down to just the clients that you're interested in.
SELECT {Filter({[Client].[SomeLevel].members}, ([Time].[LastMonth], [Measures].[whatever]) > 0 AND ([Time].[ThisMonth], [Measures].[whatever]) = 0} ON ROWS, {[Measures].[whatever]} ON COLUMNS FROM [CubeName]
You trouble might be deciding what to use in place of where I wrote [Time].[ThisMonth] - see other answers here on StackOverflow for selecting 'current' dates.
First of all, you have to identify the current month and the last month. One way to do it is compute it using the VBA!Date function.
So if your dates are stored in the format 12/31/2014 and assuming you have a measure Payment and a Date dimension with a Year-Quarter-Month-Date hierarchy, the below code can help you.
WITH MEMBER [Measures].ValueThisMonth AS
(
[Date].[Year-Quarter-Month-Date].CURRENTMEMBER.PARENT,
[Measures].[Payment]
)
MEMBER [Measures].ValueLastMonth AS
(
[Date].[Year-Quarter-Month-Date].CURRENTMEMBER.PARENT.LAG(1),
[Measures].[Payment]
)
SELECT [Client].[Client Name].MEMBERS
HAVING ISEMPTY([Measures].ValueThisMonth)
AND NOT(ISEMPTY([Measures].ValueLastMonth))
ON 0
FROM [Your cube]
WHERE
StrToMember("[Date].[Year-Quarter-Month-Date].[Date].&[" + FORMAT(VBA![Date](), "MM/dd/yyyy") + "]" + "]")
If instead you would like to pass this "current" value from the front end, use a parameter in the WHERE clause.
I have dates stored in my MySQL database . (ex.: 1992-12-12 , 1983-01-02 , 1983-01-05 , 1983-01-10 )
I want to compare these dates only on Date & Month basis regardless of the years .
Also, i want to retrieve records having date between 2nd January and 5th January , whatever the Year be.
How do i do this?
Please help with the MySQL query.
This request should do what you are looking for. But this will not work perfectly after february because of the 29th
SELECT date
FROM ...
WHERE DAYOFYEAR(date) BETWEEN DAYOFYEAR('2011-01-02') AND DAYOFYEAR('2011-01-05');
First create a function to extract only the day and month part of the date(I have written to the best of my knowledge, there may be a more optimized way than this):
CREATE FUNCTION daymonth (date DATE)
RETURNS DATE
RETURN STR_TO_DATE(CONCAT(CONCAT((EXTRACT(MONTH FROM date)),'-'),(EXTRACT(DAY FROM date))),'%m-%d');
Then call the function in your query:
SELECT date
FROM ...
WHERE daymonth(date) BETWEEN daymonth('2011-01-02') AND daymonth('2011-01-05');
I would love to further discuss on this issue. :)
-Sandip