How to sum a Time Measure in Cognos Analytics 11.1 - cognos

I am unable to sum phone call times that are being stored in a SQL fact table
I have a SQL table of phone call times, by person, which are being used in a Cognos Analytics Data Module.
I would like to use this data in a crosstab and report a total call time in HH:MM:SS for each person.
SQL column is formatted time(0) when I try to Total the time, Cognos throws a [MSR-VRF-1202 The column "Call Length" has the data type "time" and can't be aggregated] error.
What is the correct way to display a total of Call Times.
UPDATE
I have managed to overcome half the problem by using a number of query calculations in Cognos Anaytics.
I updated the SQL fact table to include a new measure of time in seconds then used the query items below.
HH as FLOOR(TOTAL([CALLTIMEINSECONDS])/3600)
MM as FLOOR(([CALLTIMEINSECONDS]-[HH]*3600)/60)
SS as [CALLTIMEINSECONDS]-([HH]*3600)-([MM]*60)
HH1 as IF ([HH]<10) THEN ('0'+CAST([HH],VARCHAR(4))) ELSE (CAST([HH],VARCHAR(4)))
MM1 as IF (MM<10) THEN ('0'+CAST(MM,VARCHAR(2))) ELSE (CAST(MM,VARCHAR(2)))
SS1 as IF (SS<10) THEN ('0'+CAST(SS,VARCHAR(2))) ELSE (CAST(SS,VARCHAR(2)))
ALL TIME as [HH1]+':'+[MM1]+':'+[SS1]
This works in individual Crosstabs rows however will not summarise and also does not work on any charts.

Why would two individuals take the time to read and vote a genuine request for assistance down? I thought this was a place to share knowledge and experience. Clearly these people need to get out more, a life, or get laid. Sorry I can’t help but hopefully someone else will 😉

I'll assume
you would use the terms time and duration synonymously.
you are using MS SQL Server.
Adjust your final solution accordingly.
My solution in SQL is:
format(sum(DATEDIFF(second, TIMEFROMPARTS(0,0,0,0,0), [CallDuration])) / 3600, '0#') + ':' +
format(sum(DATEDIFF(second, TIMEFROMPARTS(0,0,0,0,0), [CallDuration])) / 60, '0#') + ':' +
format(sum(DATEDIFF(second, TIMEFROMPARTS(0,0,0,0,0), [CallDuratoin])) % 60, '0#')
A Cognos-based solution may involve multiple queries. Here are the basic pieces:
Convert the times to numbers.
Sum the numbers.
Convert the summed numbers to times (or time parts -- hours, minutes, seconds).
Format the output.
If you calculate the parts separately, the formatting can be done on the page rather than the query Cognos as 5 text items, some with a Source type of Text and some with a Source type of Report Expression or Data item value. In other words, 3 query calculations and 2 text items.
<hours>:<minutes>:<seconds>

Related

sum up days using only existing Excel formulas

I would like to sum up date periods and sum the days per item.
The input data will grow over time and new item categories can appear, so the items (number of rows) that show in the expected report can not be "hardcoded".
The input parameter is the from and to date that determines the period that must be considered. You can imagine this as a moving date window on the input data grid.
I am a Java programmer and I am sure that I can write a proper SQL that groups and sums the data and generate the result. And I can write a Java program too, that does the job, but I really want to do this calculation from Excel.
Is there any way to generate the report by using only a combination of existing MS Excel formulas without writing any Visual Basic code (macro)?
If yes, then could you please put me in the right direction and tell me which formulas I can use? Then I can figure out how to use the formulas.
I hope that this helps to understand better what I would like to have:
Try:
Formula in F3:
=SUM(COUNTIFS(C:C,E3,A:A,"<="&SEQUENCE(H$2-F$2,,F$2),B:B,">="&SEQUENCE(H$2-F$2,,F$2)))
Note that range references that take whole columns will take long to process all data. The above will work even with overlapping dates.

How to Generate a Burndown by Month

I have a dataset of action tracking records with due dates. I've been asked to generate a burndown curve, which I can do pretty simply in Excel, but I'm stumped on how to put this in a WebI report.
I created a variable to convert the due date for the records to yyyy-MM, so I can group them by the month they're due and count them. Then, I was able to add a runningsum of those counts in my crosstab.
[
The element that I'm missing is being able to refer to the total count of records (the total outside the column grouping of the crosstab) to subtract the running sum from.
Suggestions?
You need to deal with Calculation Contexts in order to do this. Here are a few good resources...
Removing the Confusion from Calculation Contexts
Calculation Context Part I: Overview
The More Things Change... (de facto Part II to Part I above)
To answer your question and show my work I created a free-hand SQL query using the SQL in this dbfiddle. Put into a crosstab with a running sum I get what you have in your example...
Next I created a variable called Var Report Total defined as...
=Sum([Act Count]) In Report
Then I created another variable called Var Remaining to calculate the difference...
=[Var Report Total] - [Var Running Sum]
And there you have it...

Microsoft Excel Custom Function Slow and Commercially Available Software Does Not Work..Too Many Records?

I am having an excel issue that is driving me crazy, mostly because I feel like I have reached some limit of excel where I do not have the processing power to do this task.
I have two columns that I need to do the following:
one column contains record ids and the other column contains information about those ids. The total number of record id's is 185629 and the total number of records containing the information is 498776.
My goal is to compare the two columns and do a special vlookup that will return the information values and if it finds an id that is the same it will return it in the same record but with just a comma or some other delimiter to separate the information. The link I sent does a better job of explaining my task.
https://www.extendoffice.com/documents/excel/3120-excel-return-multiple-values-separated-by-comma.html
I have followed both methods, the first method works but it takes about 1 second to run per record, so with my calculations it would take 52 or so hours to complete the task. The other way, using the kutools plugin just sends the computer into limbo where it says not responding until the computer falls asleep as per sleep settings. I feel like this method will either not work at all or still take 52 hours as well.
I have also followed all the tips in this guide to make formulas run faster:
http://professor-excel.com/15-ways-to-speed-up-excel/
My processor is a laptop intel core i7-4720HQ 2.59GHZ and I have excel set to utilize all 8 cores.
My spreadsheet is originally from an SQL database which I imported though the data tab on excel. What do you guys think? Is this too much data for a custom vlookup to crunch quickly? Is there anything else I should try? Have you worked with this much data in Excel Before? Thanks!

multiple lines made into 1 line of data

I have attached a picture of what im trying to do.
I run these reports on my techs once a week. on the left side of the picture it shows the service order number multiple times and then the the booked date and closed date the techs id number actual hours work and then sold hours. the problem is it has many lines with the same service order. i need to make it look like the line to the right. 1 usable line of data so that i can process the reports the way i need to.
Copy A1:E32 all your Data without column F and paste it in I1 it will be I1:M32 for example, select I1:M32 the new Data under Data Tab click on Remove Duplicates you will have one row for each different entry
If the Number in Ro-no (column I) is unique for each entry, use the following in N2:
=Sumif($A$2:$A$32,I2,$F$2:$F$32)
and drag it down
It will sum the Sold Hours in column F for each RO-NO
Change the references to include all your rows and keep $
Power query
One of solutions is to use MS power query addin. In Office 2016 and alike the PQ is built-in feature, located on the Data tab, Get and Transform group.
Let's say we have data like this:
We can use the Power query to Group By, like so:
The query will remember the steps you 'teach' it.

PLSQL to modify VARCHAR2 column data

I am working on an app that involves evaluating modifications made to vehicles, and does some number crunching from figures stored in an Oracle 10g database. Unfortunately, I only have a text data in the database, yet I need to work with numbers and not text. I would like to know if anyone could help me with understanding how to perform string operations on VARCHAR2 column data in an Oracle 10g database with PLSQL:
For example: I need to take a VARCHAR2 column named TOP_SPEED in a table named CARS, parse the text data in its column to break it up into two new values, and insert these new values into two new NUMBER type columns in the CARS table, TOP_SPEED_KMH and TOP_SPEED_MPH.
The data in the TOP_SPEED column is as such: eg. "153 km/h (94.62 mph)"
I want to save the value of 153.00 into the TOP_SPEED_KMH column, and the 94.62 value into TOP_SPEED_MPH column.
I think what I have to do in a query/script is this:
select the text data in TOP_SPEED into a local text variable
modify the local text variable and save the new values into two number variables
write back the two number variables to the corresponding TOP_SPEED_KMH and TOP_SPEED_MPH columns
Could someone please confirm that I am on the right track? I would also really appreciate any example code if anyone has the time.
Cheers
I think it's a better idea to just have the top_speed_kmh column, and get rid of the mph one. As the number of kms in a mile never changes, you can simply multiply by 0.6 to convert to miles. So you can do the same update statement as N West suggested without the mph column:
UPDATE CARS SET TOP_SPEED_KMH = TO_NUMBER(SUBSTR(1, (INSTR(UPPER(TOP_SPEED), "KM/H") -1)));
And whenever you need the mph speed, just do
Select top_speed_kmh*0.6 as top_speed_mph from cars;
For the parsing bit, you would probably use either REGEXP_SUBSTR or INSTR with SUBSTR
Then use TO_NUMBER to convert to number
You can either create a PL/SQL function for each parsing, returning the number value, and run an UPDATE query on the fields, or you could create a PL/SQL procedure with a cursor looping over all the data that is to be updated.
Here are som links for some of the built-ins:
http://psoug.org/reference/substr_instr.html
http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/functions116.htm
You probably don't even need to do this with PL/SQL at all.
As long as the data in the column is consistent "99.99 km/h (99.99 m/h)" you could do this directly with SQL:
UPDATE CARS
SET TOP_SPEED_KMH = TO_NUMBER(SUBSTR(1, (INSTR(UPPER(TOP_SPEED), "KM/H") - 1))),
TOP_SPEED_MPH = <similar substr/instr combination to pull the 99.99 mph out of code>;
Set-operations are typically much faster than procedural operations.
I am working on an app that involves
evaluating modifications made to
vehicles, and does some number
crunching from figures stored in an
Oracle 10g database. Unfortunately, I
only have a text data in the database,
yet I need to work with numbers and
not text
Sounds like you should have some number columns to store these parsed out values. Instead of always calling some parsing routine (be it regexp or substr or a custom function), pass through all the data in the table(s) ONCE and populate the new number fields. You should also modify the ETL process to populate the new number fields moving forward.
If you need numbers and can parse them out, do it once (hopefully in a staging area or off hours at least) and then have the numbers you want. Now you're free to do arithmetic and everything else you'd expect from real numbers ;)
with s as
(select '153 km/h (94.62 mph)' ts from dual)
select
ts,
to_number(substr(ts, 1, instr(ts, ' ') -1)) speed_km,
to_number(substr(regexp_substr(ts, '\([0-9]+'), 2)) speed_mph
from s
Thanks everyone, it was nice to be able to use everyone's input to get the answer below:
UPDATE CARS
SET
CAR_TOP_SPEED_KPH =
to_number(substr(CAR_TOP_SPEED, 1, instr(UPPER(CAR_TOP_SPEED), ' KM/H') -1)),
CAR_TOP_SPEED_MPH =
to_number(substr(regexp_substr(CAR_TOP_SPEED, '\([0-9]+'), 2));

Resources