Years of Service formula -Costpoint 8 (Cognos Analytics) - analytics

I'm trying to write a formula in Cognos Analytics (costpoint) that returns if someone is hitting a new years of service milestone in the actual month.
returning a simple "true/false" or "yes/no" is perfect
essentially it's just if their years of service fall between multiple date ranges (ex: i want a return value of "yes" for someone currently at 4.95 years of service since they would hit their 5 years within the coming month)
i also have the actual start date.
years of service are in number format in column "A" in excel and in column [years of service] in costpoint (cognos) (ex: 9.154, 4.982, 24.995 ...)
i got an Excel version to work seen below:
=IF(OR(AND(A1>4.91,A1<=5),(AND(A1>9.91,A1<=10)),(AND(A1>14.91,A1<=15)),(AND(A1>19.91,A1<=20)),(AND(A1>24.91,A1<=25)),(AND(A1>29.91,A1<=30))),"yes","no")
i'm still just getting familiar with Cognos(costpoint) syntax, so i tried to write it as seen below:
if(or(and([Years of Service]>4.91,[Years of Service]<5),(and([Years of Service]>14.91,[Years of Service]<15)))then ('yes') else ('null')
without any luck...
anyone want to take a crack at it?? :)

Try something like this
case
when ([Years of Service] between 4.92 and 4.99)Then('Yes')
when ([Years of Service] between 14.92 and 14.99)Then('Yes')
else('No')
end

Related

Google Data Studio apparently bugging year sorting in combined data sources

I have a combined data source that seems to work fine when I sort a bar chart using any metric.
However, as you can notice, the years are not in correct order.
When I select sorting ("Classificar") as year ("Ano") it bugs.
I noticed it is classifying "Ano" in the sorting area as a metric, but as a matter of facts thats a dimension. I didn't manage to find a way to change that.
About the data:
Ano is years in XXXX format
Receita LĂ­quida is Net Revenues in number format
Am I doing something wrong or that's a data studio bug and there is nothing we can do?
Unfortunately, not using combined data sources is not an option in this case (but when I cancel the combined data sources, it works fine and sorts by the year as it should be - still as a metric but it works).
Well, no one answered and I finally found a way to solve it.
Google Data Studio is indeed bugging the year sorting. However it only happens if year is a date object or a number. I fixed it when I turned it into text.

FormatDateTime(Now(),vbShortDate) giving different date formats in different devices. [duplicate]

This question already has an answer here:
Format current date and time in VBScript
(1 answer)
Closed 4 years ago.
I am working in a classic asp project where I am selecting an SQL query from the database. The query was working fine in my own laptop and the date format is '11/14/2018' from this query but it's giving the mentioned error in office system and when I checked the query in SSMS then it's generating the date format as '14-11-2018'. I tried changing the different VB date formats but the result was same.
Here is the query:
sql="select count(*) as total from hc_query a, hc_breakup b where a.querytype='hotel' and a.qdate='" & FormatDateTime(Now(),vbShortDate) & "' and a.t_id=b.pnrno and b.bookstatus='half'" '
Please give some suggestions. Thanks
The problem is not in the code but in the assumptions about the function's output. The documentation for FormatDateTime states about the NamedFormat argument:
vbShortDate : 2
Display a date using the short date format specified in your
computer's regional settings.
That is, the output format depends on local configuration of the computer running the code. Two different computers can generate different output depending on locale configuration.
If you need a consistent output to deal with dates stored as strings in database fields, then you will need to write your own function to ensure consistency.

Previous years registered: Excel COUNTIF and RETURN for X years

UPDATED screenshot after attempting #Dude_Scott's suggestion:
Desired output of data is in the blue table.
Our data includes users who have registered between 1989-2016.
All have registered at least once.
Some register every year and some skip years.
Our question is for each year, find how many years previous users registered.
We want results to be 0yr, 1yr, 2yr, 3yr, etc., for each year.
Arrays are working correctly.
I've organized the data structure in Excel this way:
1) UserID All Years
For year 1989, result is 0, since it was the first year of data collection.
For year 1990, this formula returns the expected count:
=COUNT(IF($B$2:$B$11613=1989,1/COUNTIFS($A$2:$A$11613,$A$2:$A$11613,$B$2:$B$11613,1989)))
Beginning with year 1991 is where I am tripped up: I can't find for multiple years.
This formula is not working:
=COUNT(IF(AND(OR($B$2:$B$11613=1989,1990,1/COUNTIFS($A$2:$A$11613,$A$2:$A$11613,$B$2:$B$11613,1989,1990)))))
Where do I argue "COUNTIF 0 yr, 1 yr, 2 yr", etc. Thanks in advance. --f66
Since your using COUNTIF, I'm assuming you can use SUMPRODUCT also. In the below screen shot I am using this formula
=SUMPRODUCT(($A$2:$A$11=$D3)*($B$2:$B$11<=F$2))&" yr"
Without a sample of the workbook its a little difficult to determine what the output of your data should look like, but give it a go.
Side note, I would suggest updating the User ID and Years into a table format and giving it a named range, so you don't iterate though tens of thousands of lines with the array formula.
I may be reading this all wrong, but this seems to be a straightforward use case for a pivot table!
Select your data range
Set USERID as your row headings
Set YEARS as your column headings
Set count of USERID as your values
I do not use excel anymore, but below is a link to output for doing this with test data on google sheets.

How to get last year's same week data in SOLR

How do I get last years same week data?
I used fq=trans_date:[NOW-1YEAR/DAY-7DAY TO NOW-1YEAR/DAY] on date field which will give me last 7 days data for last year. But that approach doesn't take into account calender weeks.
It's probably easier to calculate the boundaries for your week number last year in the frontend and then query Solr with the date interval. That way you can get the behavior you want regarding sundays/mondays as well.
Solr does not provide a nice way to do this.
It would be really cool if you could do fq=trans_date:[NOW-1YEAR/WEEK TO NOW-1YEAR/WEEK] but this is not supported.
Nevertheless, you could create a quick function using php or javascript using each language's native Date operators and get the Week number from today to produce start and end points to feed solr in a query like [1995-12-31T23:59:59.999Z TO 2007-03-06T00:00:00Z].

How can I aggregate date data with EntityFramework but without skipping entries with no data?

How can I aggregate data by week with EntityFramework but without skipping weeks for which there is no data? So, basically if there is no data for given week - I want to get 0 or NULL as a result for that week.
Agreeing with Luke's comment above, if you know the weeks included in the search, can you just push your results onto a pre-filled week->result Map of some type initialized to zero?
A quick google shows this smarter than me guy likes this answer too:
http://thenullreference.com/blog/analytical-queries-using-entity-framework-over-date-ranges-using-linq/

Resources