Cognos Analytics: Split variable into two by month - cognos

In Cognos Analytics I have a dataset containing rows with data (used disk space in MB), with each row being either February or June. Because I want to compare the two months, I want to create two new variables: one with the February data and one with the June data.
In the Query editor I've tried: count (MB) when month = 'February'. This, and a couple of other entries don't work.
I wonder if anyone can provide me the right line of code.
Thanks in advance!

Try this:
Go to query explorer
Create a query for each month
Join the 2 queries (this will result in 3rd query)
At this point you should be able to handle each month as a separate data item

Related

Spotfire- limiting Information link colum expression

I have a column of data [Sales ID] that bringing in duplicate data for an analysis. My goal is to try and limit the data to pull unique sales ID's for the max day of every month in the analysis only (instead of daily). Im basically trying to get it to only pull in unique sales ID values for the last the day of every month in the analysis ,and if the current day is the last day so far then it should pull that in. So it should pull in the MAX date in any given month. Please how do i write an expresion with the [Sales ID] column and [Date ] column to acieve this?
Probably the two easiest options are to
1) Adjust the SQL as niko mentioned
2) Limit the visualization with the "Limit Data Using Expression" option, using the following:
Rank(Day([DATE]), "desc", Month([DATE]), Year([DATE])) = 1
If you had to do it in the Data on Demand section (maybe the IL itself is a usp or you don't have permission to edit it), my preference would be to create another data table that only has the max dates for each month, and then filter your first data table by that.
However, if you really need to do it in the Data on Demand section, then I'm guessing you don't have the ability to create your own information links. This would mean you can't key off additional data tables, and you're probably going to have to get creative.
Constraints of creativity include needing to know the "rules" of your data -- are you pulling the data in daily? Once a week? Do you have today's data, or today - 2? You could probably write a python script to grab the last day of every month for the last 10 years, and then whatever yesterday's date was, and throw all those values into a document property. This would allow you to do a "Values from Property".
(Side Note: I want to say you could also do it directly in the expression portion with something like an extremely long
Date(DateTimeNow()),DateAdd("dd",-1,Date(Year(DateTimeNow()), Month(DateTimeNow()), 1))
But Spotfire is refusing to accept that as multiple values. Interestingly, when I pull the logic for a StringList property, it gives this: $map("${udDates}", ","), which suggests commas are an accurate methodology, but I get an error reading "Expected 'End of expression' but found ','" . Uncertain if this is a Spotfire issue, or related to my database connection)
tl;dr -- Doing it in the Data on Demand section is probably convoluted. Recommend adjusting in SQL if possible, and otherwise limiting in the visualization

Getting first 3 chars from "Job No." to use as filter - Jet Reports

I am struggling to get the Quantities from the Job Ledger Entries Table which I need to filter on the first 3 letters of the Job No. pulled from the Item Budget Entries..
I am new to Jet Reports and using Express.. I have tried the function:
Should I add it as a line of code = to a variable then use the variable?
My table query looks like this so far:
=NL("Table";"Item Budget Entry";$E$12:$I$12;"Headers=";$E$11:$I$11;"TableName=";"Item Budget Entry";"Filters=";$C$5:$D$6;"InclusiveLink=Item Budget Entry";$E$10;"IncludeDuplicates=";"True")
With Filters:
I think this will be hard to achive with the express version. In the Essentials version you are able to add Excel formulas to your table.
What I would do is create two tables, one with item budget entry and one with job ledger entry. And then use excel to calculate the sums.
Or use the Essentials version, which will make your life a lot easier.

Excel Query looking up multiple values for the same name and presenting averages

Apologies if this has been asked before. I would be surprised if it hasn't but I am just not hitting the correct syntax to search and get the answer.
I have a table of raw data for my staff, it contains data on the name of the employee who completed a job and the start and finish times, among other things. I have no unique ID's other than name, and I cant change that as I'm part of a large organisation and I have to make do with the data I'm given.
what I would like to do it present a table (Table 2) that shows the name of the employee and then takes the start/finish times for all of their jobs on table 1 and presents the average time taken across all of their jobs.
I have used Vlookup in the past but I'm not sure it will cut it here. the raw data table contains approx 6000 jobs each month.
On table 1 i work out the time taken for each job with this formula;
=IF(V6>R6,V6-R6,24-R6+V6) (R= started Time) (V= Completed Time) in 24hr clock.
I have gone this route as some jobs are started before midnight and completed afterwards. Although my raw data also contains dates (started/completed) in separate columns so I am open to an experts feedback on this and if there is a better way to work out the total time form start to completion.
I believe the easiest way to tackle this would be with a Pivot Table. Calculate the time taken for each Name and Job combination in Table 1; create a pivot table with the Name in the Row Labels and the Time in the Values -- change the Time Values to be an average instead of a sum:
Alternatively, you could create a unique list of names, perhaps with Data > Remove Duplicates and then use an =AVERAGEIF formula:
Thanks this give me the thread to pull on, I have unique names as its the persons full name, but ill try pivot tables to hopefully make it a little more future proof for other things to be reports on later.

Most efficient way to create a comparative table with Excel?

using Excel (mostly the VBA part), I would like to do the following:
I have two different tables with different kind of data, but they both have at least the 4 following columns in common:
the name of the employee
the name of the project he worked on
the day he worked on it
the number of hour in that day that he worked on it.
One of the table represents the planified working time (by instance this employee should work x hours on project A and y hours on project B on the 5th of May...) and the other table represents the actual working time, i. e. the time the employee actually spent working on a project.
The actual project on which the employee worked on may differ from what was planified, or it may be the same but he might have spent a different amount of time on it.
Being new to Excel I was wondering if any of you could give me ideas on the most efficient way to do this. Since I have a lot of rows, I'm a bit reticent at the idea of using too many loops.
Thank you!
If these are structured tables (let us say their worksheet names being Planned and Actual) in Excel I would create a MS Query like this:
SELECT Plan.Employee, Plan.Project, SUM(Plan.PlannedHrs), SUM(Act.ActualHrs),SUM(Act.ActualHrs) / SUM(Plan.PlannedHrs)
FROM [Planned$] as Plan
INNER JOIN [Actual$] as Act
ON Plan.Project = Act.Project AND Plan.Employee=Act.Employee
GROUP BY Plan.Employee, Plan.project, Act.Project, Act.Employee
The above query will compare hrs per project (Planned vs Actual). This is just an example as you can calculate other metrics.
Using MS Queries?: Data->From Other Sources->From Microsoft Query
or use my SQL AddIn (just to create the query): http://www.analystcave.com/excel-tools/excel-sql-add-in-free/

Performance tuning in Cognos Report Studio

Working in Cognos Report Studio 10.2.1. I have two query items. First query item is the base table which results in some million records. Second query item is coming from a different table. I need to LEFT OUTER JOIN the first query item with other. In the third query item post the join, I am filtering on a date column which is in formatYYYYMM to give me records falling under 201406 i.e the current Month and Year. This is the common column in both the table apart from AcctNo which is used to join both the tables. The problem is, when I try to view Tabular datathe report takes forever to run. After waiting patiently for 30 mins, I just have to cancel the report. When I add the same filter criteria to the 1st query item on the date column and then view the third query item, it gives me the output. But in the long run, I have to join multiple tables with this base table and in one of the table the filter criteria needs to give output for two months. I am converting a SAS code to Cognos, In SAS code, there is no filter on the base table and even then the join query takes few seconds to run.
My question is: Is there any way to improve the performance of the query so that it runs and more importantly runs in less time? Pl note: Modelling my query in FM is not an option in this case.
I was able to get this resolved myself after many trial and errors.
What I did is created a copy of 1st Query item, and filtered 1st query item with current month and year and the for the copy of 1st query item added a filter for two months. That way I was able to run my query and get the desired results.
Though this is a rare case scenario, hope it helps someone else.

Resources