How to search inside of a LookupSet - reportbuilder3.0

If you do a LookupSet and it returns the values:
11/6/2014 3/17/2015 9/14/2015 2/27/2013
is there anyway to search those dates and return only the dates that meet certain criteria, such as year = 2015 and Month >= 7
Here is the code that gave me the above values:
Join(LookupSet(Fields!UNID.Value,Fields!Parent_UNID.Value,Fields!Inspection_Date.Value, "Inspections"))

Only way I can think of doing this is an Iif() to change the date into something conspicuous and then a replace to delete them:
=Join(LookUpSet(Fields!UNID.Value, Fields!Parent_UNID.Value, Replace(Iif(Year(Fields!Inspection_Date.Value) = 2015 And Month(Fields!Inspection_Date.Value) >= 7, Fields!Inspection_Date.Value, "XXYYZZ"), "XXYYZZ", Nothing), "Inspections")
So what this does is checks if the Year of the date is 2015 and the month is >= 7 and if so, returns the date. If it's not, it returns XXYYZZ, and then the Replace() statement looks for that string and just returns it to nothing.

Related

Power BI Measure returning Blank when it shouldn't

I am trying to create a measure that will return a value for the number of issued receipts in the year 2020:
CALCULATE(SUM(Receipts[issued]), FILTER(Receipts, Receipts[Year] = 2020))
However, the measure keeps returning blank, even as a calculated column.
I've also tried
CALCULATE(SUM(Receipts[issued]), FILTER(Receipts, Receipts[Year].Year = 2020))
But that is returning an error saying the syntax for "Year" is incorrect.
The Year column is of datatype Date and is linked to a dimDate table on the Date column.
I am trying to retrieve the value 440,000. What am I doing wrong?
Try this.
CALCULATE(SUM(Receipts[issued]), YEAR(Receipts[Year]) = 2020)

AVERAGE not calculated proper in OBIEE

I have written the following expression,
#for the 1st Column
CASE WHEN month = 'Nov'
THEN AVG(Marks by Student)
END
#for the 2nd Column
CASE WHEN month = 'Dec'
THEN AVG(Marks by Student)
END
I have Month as prompt. So, when I run the report. The data is being displayed only for December. But when I select November in prompt, November data is displayed.
Is there anything am going wrong with the expression?
Wait you are saying that the result is "wrong" because it displays November when you FILTER for November?!
You do know that filters are actually WHERE clauses which cut off the data stream!

Linq Dynamic Query tried to search data within a year get no results

I am building a Dynamic query to search a collection of documents using LINQ. (please referred to Scott Gu's blog http://weblogs.asp.net/scottgu/dynamic-linq-part-1-using-the-linq-dynamic-query-library).
I can return the documents modified since last week, since last month without any problem! However, if I tried to return the documents last modified from last year to now. I got no result returned. And when I tried to get any documents modified a year ago, I got only one week results from 3 weeks ago)..
Does anyone know why? Below is my code:
// tried to get last year till now: (no result)
( LastModifiedStr >= \"4/27/2014\" and LastModifiedStr <= \"4/28/2015\" )
// tried to get documents older than one year. (results from 4/3/2015-4/9/2015)
( LastModifiedStr >= \"4/27/2014\" )
You cannot compare the string. The LastModified field should be a DateTime format, also inside your query builder, you probably want to convert the string to datetime as well. something like:
( LastModified >= Convert.ToDateTime(\"4/27/2014\") and LastModifiedStr <= Convert.ToDateTime(\"4/28/2015\") )

Convert DDMON (eg. 23JAN) date format to full date with correct year applied in Ruby

Am looking for a compact solution for converting the dates that come from the airline reservation systems (GDS like Sabre/Galileo/Amadeus) which dont have the year - eg. 23JUN to a standard date, but need to determine the year quickly to tack on in Ruby. (FYI - on these systems date can only be max 355 days from today. So there is no ambiguity of interpreting 12MAY as 2013-05-12 instead of 2012-05-12 assuming today is 12MAY 2012). If today is 25th Dec 2012, and date is entered as 01JAN, this would be 01JAN2013 in the future, and if today is 21JUL 2012, input date of 01JAN would also become 01JAN 2013 as it is a past date in the current year.
So I can do something like:
t = DateTime.now
crsdate = DateTime.strptime("23JAN","%d%b")
if crsdate >= t
# Year is current year
else
# Year is next year
end
Is there a more elegant way of doing this?
How about this?
t = DateTime.now
crsdate = DateTime.strptime("23JAN","%d%b")
crsdate >= t ? crsdate >>= 12 : crsdate
If you don't need to modify crsdate because you just want to return this, use >> instead of >>=.

Get the the most recent and the one before the most recent item

I have a table with many anniversaries : Date + Name.
I want to display the next anniversary and the one after with Linq.
How can i build the query ?
I use EF
Thanks
John
Just order by date and then use the .Take(n) functionality
Example with a list of some objects assuming you want to order by Date then Name:
List<Anniversaries> annivDates = GetAnnivDates();
List<Anniversaries> recentAnniv = annivDates.OrderBy(d => d.Date).ThenBy(d => d.Name).Take(2).ToList();
If the anniversaries are stored in regular DateTime structs, they may have the 'wrong' year set (i.e. wedding or birth year). I suggest writing a function which calculates the next date for an anniversary (based on the current day) like:
static DateTime CalcNext(DateTime anniversary) {
DateTime newDate = new DateTime(DateTime.Now.Year, anniversary.Month, anniversary.Day);
if (newDate < DateTime.Now.Date)
newDate = newDate.AddYear(1);
return newDate;
}
Then you proceed with sorting the dates and taking the first two values like described in the other postings:
(from e in anniversaries orderby CalcNext(e.Date) select e).Take(2)

Resources