How to create a Calculation based on multiple criteria in IBM Cognos - cognos

I am trying to create a calculation in Cognos based on a number of Criteria.
For example, I want to get a count of all of the records in my data set that have the following criteria:
Data_Level = "Aggregate"
Problem_Area = "Request"
IsResearch = "No"
Substate_ID = "Incomplete - Cancelled"
I want to then call this value: 'Aggregated Data - Non Research'
Thanks in advance for your feedback. I'm conducting a feasibility test of Cognos compared to other BI Tools so I am trying to replicate the same report across tools to gauge their usability. So far I am finding Cognos the most difficult to find resources on.
Regards,
Jason

I would just create an if then else field which gives you a 1 if the conditions are met and 0 if they are not, then total that.
total(If ([Data_Level] = "Aggregate" and [Problem_Area] = "Request" and [IsResearch] = "No"
and [Substate_ID] = "Incomplete - Cancelled")
then (1)
else (0))

Try the function total and define the scope
For example,
Create a data item "Aggregated Data - Non Research"
Expression:
If ([Data_Level] = "Aggregate" and [Problem_Area] = "Request"
and [IsResearch] = "No" and [
Substate_ID] = "Incomplete - Cancelled")
then (1) else (0)
Then you can add another data item, using the total function, with an expression that defines the scope:
Total([Aggregated Data - Non Research] for Company, Year, Month)

Related

CosmosDB Find average time for message to complete

I need some help with a SQL query in Cosmos. I have to find the average time it takes a message to complete during a load test from the events stored in our DB.
So far I can get the start and end times like this:
SELECT
(SELECT c.TimestampUTC WHERE c.Event = 'message-accepted') as StartTime,
(SELECT c.TimestampUTC WHERE c.Event = 'message-completed') as EndTime
FROM c
WHERE c.TrackingId = 'LoadTest' AND (c.Event = 'message-accepted' OR c.Event = 'message-completed')
But I get an error when I try to get the DateTimeDiff like this:
SELECT
(SELECT c.TimestampUTC WHERE c.Event = 'message-accepted') as StartTime,
(SELECT c.TimestampUTC WHERE c.Event = 'message-completed') as EndTime,
DateTimeDiff("second", StartTime, EndTime) as TotalTime
FROM c
WHERE c.TrackingId = 'LoadTest' AND (c.Event = 'message-accepted' OR c.Event = 'message-completed')
I am stuck here because I need the difference to use the AVG function. Any help would be appreciated.
EDIT
Here is a sample of the data stored in Cosmos
{
"PartitionKey": "LoadTest",
"RowKey": "4ee9709f-c826-4a88-9d6f-240ba439eb1d",
"TrackingId": "LoadTest",
"Event": "message-accepted",
"TimestampUTC": "2022-09-14T19:12:18.8358914Z"
}
And this is the error I am getting when trying DateTimeDiff:
"Failed to query item for container enginelog:
One of the input values is invalid."
It is not giving much info which is why I am looking for help, I am following the format for the function in the documentation here
As per sample data shared in question, the assumption is that there are two different documents with Event property value "message-accepted" and "message-completed". As David mentioned, functions can't be used on data/properties available across separate document until unless property names are same.
In order to achieve what is required, you may need to write client-side code to recursively fetch the properties value from separate documents. Please refer the link

To check for a specific value from the values being returned from Listagg function

I have the following query written
Select a.client_acct_id, asfv.acct_no, asfv.value_text, pim.bill_day,
LISTAGG(pi.plan_no, ', ') WITHIN GROUP (ORDER BY pi.acct_no) Plan_no
from acct a, ACCT_SUPP_FIELD_VALS asfv, plan_instance_master pim, plan_instance pi
where asfv.client_no = 65000005 and asfv.FIELD_NAME = 'BillDispMethod'
and asfv.client_no = a.client_no
and asfv.acct_no = a.acct_no
and asfv.client_no(+) = pi.client_no
and asfv.acct_no(+) = pi.acct_no
and pi.status_cd = 1
and pi.client_no = pim.client_no
and pi.master_plan_instance_no = pim.plan_instance_no
group by a.client_acct_id, asfv.acct_no, asfv.value_text, pim.bill_day
which gives me a result as follows,
CLIENT_ACCT_ID ACCT_NO VALUE_TEXT BILL_DAY PLAN_NO
603444726 32940414 Paper Bill 11 10140301, 10140306, 10144890, 10145691
525810295 33043952 Paper Bill 19 10140301
What i am actually trying to acheive is that i need to cross verify from the list of value available in the field PLAN_NO do i have the value "10145691". If yes i want to have a field added to the above query which says Yes else it says NO
Can someone guide me on how i can acheive it
What i am actually trying to acheive is that i need to cross verify from the list of value available in the field PLAN_NO do i have the value "10145691". If yes i want to have a field added to the above query which says Yes else it says NO
Can someone guide me on how i can acheive it

NetSuite Search formula for items that have no open transactions

I am trying to create a formula to obtain a list of items that have no open transactions.
I cant just filter out by status as this filters out transactions that are open, as opposed to showing me only items with nothing open.
So basically if an item has anything open then i dont want it on the search. I do need it on the search if it has all closed or it has no transactions at all.
Hoping someone can help put me in the right direction.
I am a little bit stuck at where to start with the formulas and tried a case formula.
You can use item saved search adding under criteria as "Transaction Fields-status-anyOf-select all closed/rejected/declined statuses" not in filter reason of saved search.
Thanks.
To get the value of non transaction items as well, You need to check the check box use expression under criteria in standard subtab use parens() with OR expression.
And add one more condition as "Transaction Fields-Internal Id-anyOf-none with
"Transaction Fields-status-anyOf-select all closed/rejected/declined statuses".
Add both condition with OR logic.
It will work for both items condition if it has transaction status with closed or with none of transaction internal ids.
Thanks.
I think this is possible in a saved search, and requires a change in the way the filtering is done. Rather than filtering on the "Filters", using grouping and summary calculations to determine if an item qualifies, basically :
Create the item saved search as you would normally, but don't include a "Standard" filter for the openness of the transaction.
In the results, group by item name (or internalid), and another fields you want to include in the top-level results.
In the Criteria - Summary list, add a Formula (Number) condition :
Summary Type= Sum (Count won't work here)
Formula = case when {transaction.status} = 'Open' then 1 else 0 end
Equal to 0
Whether this is more or less elegant than bknight's answer is debatable.
I don't think this is the sort of thing you can do with a single saved search.
It would be fairly easy to do with SuiteQL though.
The script below runs in the console and finds items that are not on any Pending Billing Sales Orders. It's adapted from a script with a different purpose but illustrates the concept.
You can get a list of the status values to use by creating a saved search that finds all the transactions with open statuses you want to exclude , take note of that saved search's id and running the second script in the console
require(['N/query'], query => {
const sqlStr = `
select item.id, itemid, count(po.tranid) as po, count(bill.tranId) as bill, max(bill.tranDate) as lastBilled, count(sale.tranId) as sales, count(tran.tranId) as trans
from item
left outer join transactionLine as line
on line.item = item.id
left outer join transaction as tran on line.transaction = tran.id
left outer join transaction as po on line.transaction = po.id and po.type = 'PurchOrd'
left outer join transaction as bill on line.transaction = bill.id and bill.type = 'VendBill'
left outer join transaction as sale on line.transaction = sale.id and sale.type in ('CustInvc', 'CashSale')
where item.id not in (select otl.item from transactionLine otl, transaction ot where
otl.transaction = ot.id and ot.status in ('SalesOrd:F'))
group by item.id, item.itemid
`;
console.log(sqlStr);
console.log(query.runSuiteQL({
query: sqlStr
}).asMappedResults().map((r, idx)=>{
if(!idx) console.log(JSON.stringify(r));
return `${r.id}\t${r.itemid}\t${r.po}\t${r.bill}\t${r.lastBilled}\t${r.sales}\t${r.trans}`;
}).join('\n'));
});
require(['N/search'], search=>{
const filters = search.load({id:304}).filters;
console.log(JSON.stringify(filters.find(f=>f.name == 'status'), null, ' '));
});
In terms of doing something with this you could run this in a saved search and email someone the results, show the results in a workbook in SuiteAnalytics or build a portlet to display the results - for this last Tim Dietrich has a nice write up on portlets and SuiteQL

How to append to error column when using the Macro Design (before change) inside of MS Access?

I have an MS Access database that receives hundreds of row records coming into it. I need a way to validate that the incoming data is consistent with the business logic. For example, when we get a record the state column should be "California", otherwise an error should be appended to an Error column that specifies why it failed. And for that same record if the Income is less than $1,000,000 an error should be appended for that too.
I found that inside MS Access while highlighting your table if you at the top bar click on Table > Before Change, you can create If-then logic for incoming rows. If there is a better way to accomplish this task, please let me know.
Once I am inside the "Before change" window I then write this logic out:
If [State] <> "California" Then
SetField
Name Error
Value = "Failed on incorrect state"
Else if [Income] < 1000000 Then
SetField
Name Error
Value = "Failed on incorrect income"
End if
When multiple errors occur such as both incorrect state and income it only shows the first error. Is there a way to have both errors appended to the same error column?
Thanks
You can try to use AND statement in the IF section.
If [STATE] <> "California" && [INCOME] < 10000000 Then
//Write your logic here. Such as "Incorrect Value".
Hope it works for you.

Getting "Please rebuild this data combination" on a computer but not on another one

This is my first try at using the Power Query... I've build a "dynamic" query in which I can change the retrieved fields as well as the filtering fields and values to be used by the query.
It's working perfectly on my computer but as soon as I try to execute it on another computer, I get the "Please rebuild this data combination" error. I saw some post saying I'll have to kind of split my query but I have not been able to figure it out.
Here is what my 2 tables look like:
Condition and fields selection
and here is my Query with the error:
Query
This might not be very elegant, but it allow me, thru a VBA script, to generate the list of fields to be retrieved and to generate the condition to be used by the SQL.
Any idea why it's not working on the other computers or how to improved the solution I'm using?
Thank you!
Notes:
Hi, all my Privacy Level are already set to 'None'.
I've tried to parametrize my code but I can't figure how. The Where condition is dynamic: it could be Where Number = "1234" but in other condition, the where might be like: 'Where Assignee = "xyz"'.
Here is a simplified example of my code:
let
Source = Sql.Database("xxxx", "yyyy", [Query=
"Select network, testid
from CM3T1M1 "
& paramConditions[Conditions]{0} &
" "])
in
Source
rebuild query, Formula.Firewall
That's a feature to prevent prevent accidentally leaking data. You can change the privacy level to ignore it
See also: docs.microsoft/dataprivacyfirewall
Is the dynamic query inserting those cells into the SQL query ? Report Parameters are nice for letting the user change variables without having to re-edit the query.
Parameterized native SQL queries
from: https://blog.crossjoin.co.uk/2016/12/11/passing-parameters-to-sql-queries-with-value-nativequery-in-power-query-and-power-bi/
let
Source = Sql.Database("localhost", "Adventure Works DW"),
Test = Value.NativeQuery(
Source,
"SELECT * FROM DimDate
WHERE EnglishMonthName=#MonthName AND
EnglishDayNameOfWeek=#DayName",
[
MonthName = "March",
DayName = "Tuesday"
]
)
in
Test
Dynamic Power Query version of SQL Query
To dynamically generate this SQL Query
select NUMBER, REQUESTED_BY from SourceTable
where NUMBER = 404115
Table.SelectRows is your Where.
SelectColumns is your select
let
Source = ...,
filterByNum = 404115,
columnNames = {"NUMBER", "REQUESTED_BY"},
removedColumns = Table.SelectColumns(
Source, columnNames, MissingField.Error
),
// I used 'MissingField.Error' so you know right away
// if there's a typo or bug
// assuming you are comparing Source[NUMBER]
filteredTable = Table.SelectRows(
Source, each [NUMBER] = filterByNum
)
in
filteredTable

Resources