Archer GRC Calculation based on three fields - archer

IF [Chemical Incident Awareness Required] = VALUEOF([Chemical Incident Awareness Required],"No")
[Chemical Incident Awareness Status] = VALUEOF([Chemical Incident Awareness Status],"Pending")
I need help creating a calculation where I set the field Chemical Incident Awareness Status (a value list) to "Pending" based on if Chemical Incident Awareness Required (another value list field) is "No".
Also if Chemical Incident Awareness Date Completed is any valid value set Chemical Incident Awareness Status to "Completed"

IF(
NOT(ISEMPTY([Chemical Incident Awareness Date Completed])),
VALUEOF([Chemical Incident Awareness Status],"Completed"), IF(
[Chemical Incident Awareness Required] = VALUEOF([Chemical Incident Awareness Required],"No"),
VALUEOF([Chemical Incident Awareness Status],"Pending")
)
)
Hope this helps!

Related

How to Hide Irrelevant Data Results

I have a report that I generate weekly that shows contracts being expired or soon to be expired within 90-days. The report works fine, however, the contracts or sites that are NOT out of contract or soon to be expiring are still appearing as headers on the report. My question is, how do I ONLY show the sites expired and due to expire and not the other sites (headers, names, etc...).
SITE_INFO
===========================================================
SELECT SITE.ID SITE_INFO_ID,
"ORGANIZATION"."NAME" "CUSTOMER_NAME",
"SITE"."NAME" "SITE_NAME",
"CUSTOM"."VALUE" "MANAGER_NAME",
"ADDRESS"."ADDRESSLINE1" AS "ADDRESSLINE1",
"ADDRESS"."ADDRESSLINE2" AS "ADDRESSLINE2",
"ADDRESS"."ADDRESSLINE3" AS "ADDRESSLINE3",
"ADDRESS"."CITY" AS "CITY",
"ADDRESS"."STATE" AS "STATE",
"ADDRESS"."COUNTRY" AS "COUNTRY",
"ADDRESS"."POSTAL_CODE" AS "POSTAL_CODE",
"ADDRESS"."SITE_ID" AS "SITE_ID",
"REGION_CODE"."ID" AS "REGION_ID",
"REGION_CODE"."NAME" AS "REGION_NAME"
FROM ORGANIZATION,
SITE,
CUSTOM,
ADDRESS,
REGION_CODE
WHERE SITE.ORGANIZATION_ID = ORGANIZATION.ID AND
CUSTOM.SITE_ID = SITE.ID AND
CUSTOM.NAME LIKE 'MANAGER NAME' AND
SITE.ID = ADDRESS.SITE_ID AND
REGION_CODE.ID = SITE.REGION_ID AND
SITE.IS_DELETED = 0
SYS_DATE
=============================================================
SELECT TO_CHAR(SYSDATE,'MM-DD-YYYY') FROM DUAL
CONTRACT_INFO
=============================================================
SELECT CONTRACT_TYPE.NAME CONTRACT_NAME,
CONTRACT.SITE_ID SITE_ID,
CONTRACT.CONTRACT_INDEX CON_INDEX,
TO_CHAR(CONTRACT.END_DATE,'MM-DD-YYYY') END_DATE,
CONTRACT.ORDER_NO ORDER_NO,
CONTRACT.PROJECT_NO PROJECT_NO,
CASE WHEN CONTRACT.END_DATE <= SYSDATE THEN 1 ELSE 0 END FLAG
FROM CONTRACT LEFT JOIN
CONTRACT_TYPE ON CONTRACT.CONTRACT_TYPE_ID = CONTRACT_TYPE.ID
WHERE CONTRACT.SITE_ID = :SITE_INFO_ID
AND CONTRACT.END_DATE <= SYSDATE + 90
The SITE_INFO and CONTRACT_INFO data sets are linked, and the template is created in MS Word using BI Publisher. Code is written in SQL in BI Publisher online.
This could be a little more than you need, but would work.
Repeat Site section for each site. Each section starts a new page.
Count number of expired contracts within site, with unique order numbers.
Only show site if number of expired contracts is more than zero.
Site content
Within site content, show count of expired contracts (optional)
Repeat contract section, only for contracts that are expired.
Assuming you have data structure:
EXTRACT/LIST_SITE_INFO/SITE_INFO/LIST_CONTRACT_INFO/CONTRACT_INFO
XML Like:
<EXTRACT>
<SYS_DATE>2015-05-15 8:30:25</SYS_DATE>
<LIST_SITE_INFO>
<SITE_INFO>
<CUSTOMER_NAME>Test Customer</CUSTOMER_NAME>
<CUSTOMER_ID>123</CUSTOMER_ID>
<SITE_NAME>Test Site</SITE_NAME>
<LIST_CONTRACT_INFO>
<CONTRACT_INFO>
<CONTRACT_NAME>Contract 123</CONTRACT_NAME>
<ORDER_NO>456</ORDER_NO>
<CONTRACT_ID>789</CONTRACT_ID>
<FLAG>1</FLAG>
</CONTRACT_INFO>
</LIST_CONTRACT_INFO>
</SITE_INFO>
</LIST_SITE_INFO>
</EXTRACT>
Template would looks something like this:
<?for-each#section:EXTRACT/LIST_SITE_INFO/SITE_INFO?>
<?xdoxslt:set_variable($_XDOCTX, ‘V_EXP_COUNT’, count(xdoxslt:distinct_values(//LIST_CONTRACT_INFO/CONTRACT_INFO[FLAG="1"]/ORDER_NO)))?>
<?if:xdoxslt:get_variable($_XDOCTX, ‘V_EXP_COUNT’)>0?>
Site Section / Content
Number of Expired Contracts: <?xdoxslt:get_variable($_XDOCTX, ‘V_EXP_COUNT’)?>
<?for-each:LIST_CONTRACT_INFO/CONTRACT_INFO[FLAG="1"]?>
Expired Contract Section / Content
<?end for-each?>
<?end if?>
<?end for-each?>
Make sure there's no spaces/new-lines between the elements in the template.

SSAS Calculated Measure based on another calculated measure

I have a MDX query below. This query works, the problem is it is slow, takes > 15 secs to return results even though the data set is not huge. I believe the query should execute under 2 secs (its also used on a landing page and the wait time is bothersome). The [Measures].[Star Rating] is causing the slow down because of all the IF THEN ELSE logic. All its doing is based on the [Mean Score], it finds the [Star Rating] from a lookup table based on the range in the lookup table.
For e.g. if [Mean Score] < 86, [Star Rating] = 1
if [Mean Score] >= 86 and <= 90, [Star Rating] = 2
The [Mean Score] is a simple sum/count calculation.
It can change based on the date range being used as parameter.
Can you recommend either an optimization in the existing query below or recommend an alternate way to calculate [Star Rating] ?
The MDX query is below:
WITH
MEMBER [Measures].[MeanScore] AS ([Measures].[Standard Point Assignment - Sum]/[Measures].[Episode Of Care HCAHPS Count])
MEMBER [Measures].[StarRating] AS
CASE
WHEN [HCAHPS Star Rating].[HCAHPS Star Rating ID].CurrentMember IS [HCAHPS Star Rating].[HCAHPS Star Rating ID].[All]
THEN
CASE
WHEN [Measures].[HSR-HCHCAHPS Domain ID] = TAIL([HCAHPS Star Rating].[HCAHPS Star Rating ID].[HCAHPS Star Rating ID]).Item(0).Item(0).Properties('HCHCAHPS Domain ID')
THEN
(
[Measures].[Rating],
Tail([HCAHPS Star Rating].[HCAHPS Star Rating ID].[HCAHPS Star Rating ID]).Item(0).Item(0)
)
ELSE
(
[Measures].[StarRating],
Tail([HCAHPS Star Rating].[HCAHPS Star Rating ID].[HCAHPS Star Rating ID]).Item(0).Item(0).PrevMember
)
END
ELSE
CASE
WHEN [Measures].[MeanScore] > [HCAHPS Star Rating].[HCAHPS Star Rating ID].CurrentMember.Properties('Start', typed)
AND [Measures].[HC-HCAHPS Domain ID] = [HCAHPS Star Rating].[HCAHPS Star Rating ID].CurrentMember.Properties('HCHCAHPS Domain ID', typed)
THEN
(
[Measures].[Rating],
[HCAHPS Star Rating].[HCAHPS Star Rating ID].CurrentMember
)
ELSE
(
[Measures].[StarRating],
[HCAHPS Star Rating].[HCAHPS Star Rating ID].CurrentMember.PrevMember
)
END
END
SELECT
{
[Measures].[Episode Of Care HCAHPS Count]
,[Measures].[Is Top Box]
,[Measures].[CompositeScore]
,[Measures].[PromoterCount]
,[Measures].[PromoterPercent]
,[Measures].[PassiveCount]
,[Measures].[PassivePercent]
,[Measures].[DetractorCount]
,[Measures].[DetractorPercent]
,[Measures].[StarRating]
,[Measures].[MeanScore]
} ON COLUMNS,
NONEMPTYCROSSJOIN
(
{NONEMPTY([HCAHPS Domain].[HCAHPS Survey Methodology ID].[HCAHPS Survey Methodology ID])}
,DESCENDANTS(StrToSet('[Org Hierarchy].[Parent Key].&[118418]'))
,{[HCHCAHPS Domain].[HC Domain Group].[HC Domain Group]}
,{[HCHCAHPS Domain].[HCAHPS Domain Name].[HCAHPS Domain Name]}
,{[HCAHPS Question Answer].[Question Number].AllMembers}
) ON ROWS
FROM [CAHPS]
WHERE
(
StrToMember("[Date].[Date].&[" + FORMAT(NOW()-365,"yyyy-MM-ddT00:00:00") + "]",CONSTRAINED):StrToMember("[Date].[Date].&[" + FORMAT(NOW(),"yyyy-MM-ddT00:00:00") + "]",CONSTRAINED)
)
In general, IIF and CASE statements within Analysis Services MDX could potentially see some performance degradations. While most IIF statements are relatively inexpensive, complex nested conditions (with lots of IIF statements), this would result in the Analysis Services formula engine will end up running the query cell-by-cell.
For performant queries, the goal is to have the query run in subspace mode (or block computation) instead of cell-by-cell mode. To do this within the context if IIF statements, please try to utilize SCOPE statements. A great reference to convert IIF statements to SCOPE is Mosha Pasumansky's blog post is Performance of IIF function in MDX.
By the way, for more information on subspace computation (vs. cell-by-cell), please refer to Section 3.2.1 of the Analysis Services Performance Guide

Aggregating Child Records at the Parent Level in Access 2010

The link above will provide an excel sheet with some sample data from both the parent and child table with expected result from the query.
Alright this should be simple but I just can't wrap my head around this for some reason. Pretty much, I have a parent table that is linked to a child table. I want to pull up few of the fields from the child table and merge it with the parent fields. I want to create a view of sort in Access.
The parent record can have multiple child records (1 - many relationship). I want to only pull up one record from the child and merge with the parent. The parent table is called Tank and the child table is Tank_Inspections. The IF statement you see below is a conditional statement that helps in determining which Out of Compliance date I should be pulling up. The issue I'm having is that the Out of Compliance date is tied to inspection type. A Tank can have multiple different inspection types. They query below merges the inspection out of compliance date with few of the tank (parent) fields. However, I want to be able to add more of the child fields (in addition to the inspection out of compliance date) but I can't do that without adding those fields to the group by clause as well. If I do that, then I won't get the right amount of records.
As you can see, the left join is getting all of the records from the parent table which is what I need. If I add any more child table fields to the query, I'll also need to add them to the group by clause and then I'll get more records than what's in the parent table. Essentially, I need to only get the records from the parent table, and then merge child fields in. I may be missing few sub queries... Any suggestions? This is what I have so far and I'm getting the right amount of records. But adding more child fields to the select statement will add more rows than i need...
SELECT parent.tankid, IIf(Min(Nz(child.[tank inspection out of compliance date], #1/1/1901#)) <> #1/1/1901#, Min(child.[tank inspection out of compliance date]), IIf(Min(Nz(child.[tank inspection out of compliance date],#1/1/1901#)) = #1/1/1901# And Max(child.[tank inspection out of compliance date])>Date(), NULL, Min(child.[tank inspection out of compliance date]))) AS [Tank Inspection Out of Compliance Date]
FROM
tank as parent
LEFT JOIN
(
SELECT * FROM tank_inspections WHERE tank_inspections.[actual inspection date] is null
) AS child ON parent.tankid = child.tankid GROUP BY parent.tankid
I was able to modify Parfait suggested query below to come up with this:
SELECT
Site.[Manager] AS PM, Site.[DLA Site Code], Tank.[Name] AS [Name], Tank.[Local Name],
Tank.RPID, Tank.[Fac Num], Tank.[Status], Tank.[Type], Tank.[Capacity], Tank.[Current Prod], IIf(main.[Inspection Out of Compliance Date]<Date() AND NOT IsNull(main.[Inspection Out of Compliance Date]), 'Out of Compliance',
IIf(isnull(main.[Inspection Out of Compliance Date]) OR main.[Inspection Out of Compliance Date]=#1/1/1901#,'Unknown Compliance Status')) AS [Compliance Status], Tank.[EA], Site.Serv, Site.[Name], Tank.Comments, main.[Type], main.[Inspection Out of Compliance Date], main.[Planned Prog Date], main.[Prog Date], main.[Prog Year], main.[Planned Inspection Date], IIf(main.[Inspection Out of Compliance Date]<DateAdd('m',12,Date()) And main.[Prog Date] Is Null,'Action Required') AS [Inspection Planning Action Required], main.[Inspection Comments], tank.TankID, main.inspectionid
FROM
Site INNER JOIN
(
(
(
SELECT ti.tankid, ti.inspectionid, ti.[Type], ti.[Inspection Out of Compliance Date], ti.[Planned Prog Date], ti.[Prog Date], ti.[Prog Year], ti.[Planned Inspection Date], ti.[Inspection Comments] FROM Tank_Inspections AS ti) AS main INNER JOIN Tank ON main.TankID = Tank.TankID) INNER JOIN
(
SELECT [TankID], dlookup("InspectionID", "Tank_Inspections", "[Tank Inspection Out of Compliance Date] " & IIf(Min(Nz([inspection out of compliance date], #1/1/1901#)) <> #1/1/1901#, "= #" & Min([inspection out of compliance date]) & "#", IIf(Min(Nz([inspection out of compliance date],#1/1/1901#)) = #1/1/1901# And Max([inspection out of compliance date])>Date(), "IS NULL", IIF(Min(Nz([inspection out of compliance date],#1/1/1901#)) = #1/1/1901# And Max([inspection out of compliance date])<Date(), "= #" & Min([inspection out of compliance date]) & "#", "IS NULL"))) & " AND TankID = " & TankID & " AND [Actual Inspection Date] is null") AS MinInspectionID FROM Tank_Inspections WHERE [Actual Inspection Date] is null GROUP BY [TankID]
)AS DT ON
(
main.InspectionID = Cint(DT.MinInspectionID)
) AND (main.TankID = DT.TankID)
) ON Site.SiteID = Tank.SiteID
WHERE IIf(main.[Inspection Out of Compliance Date]<Date() And NOT IsNull(main.[Inspection Out of Compliance Date]),'Out of Compliance',IIf(isnull(main.[Inspection Out of Compliance Date]) OR main.[Inspection Out of Compliance Date]=#1/1/1901#,'Unknown Compliance Status'));
I'm close with this query, however, I'm missing a few records. The parent records don't have some of the child records. For example, some of the tank records don't have any inspection records so it's not being pulled. I need to do a left join but can't seem to figure it out with this query. Everything I try doesn't seem to work. Suggestion?
Consider the following query that uses a derived table and joins the unit level parent (Tank) to aggregated child (TankInspections). You can save the derived table as a separate stored query and just replace entire select statement and alias (DT) with query name. I include more aggregates than needed for you to check calculated columns:
SELECT Tanks.*, main.*, DT.MaxInspectionID, DT.MaxInspectionOrComplianceDate
FROM
(TankInspections main
INNER JOIN Tanks ON Tanks.TankID = main.TankID)
INNER JOIN
(
SELECT [TankID],
Max(InspectionID) As MaxInspectionID,
Min([Planned Inspection Date]) As MinInspection,
Max([Planned Inspection Date]) As MaxInspection,
Min([Inspection Out of Compliance Date]) As MinCompliance,
Max([Inspection Out of Compliance Date]) As MaxCompliance,
Max(IIF(([Planned Inspection Date]) Is Null,
IIF(ISNULL([Inspection Out of Compliance Date]),
NULL,
[Inspection Out of Compliance Date]),
[Planned Inspection Date])) As MaxInspectionOrComplianceDate
FROM TankInspections
GROUP BY [TankID]
) As DT
ON main.TankID = DT.TankID
AND main.InspectionID = DT.MaxInspectionID;

How do I convert a user-generated Oracle EBS spreadsheet into a SQL-driven script?

I need to convert a manually-created spreadsheet into a SQL report. The report is generated via Oracle Forms (one of the BI Suite apps).
There's an inbox where many tickets come in to, identified by a "Request Number"
Each Request Number is a help desk ticket in the system. Here is a screenshot of that spreadsheet:
A full listing of columns(with descriptions) :
Request No.
Modules
Submitted ( the request being submitted , a timestamp )
Supervisor ( the request being approved , by supervisor )
Average Supervisor Approval Duration
Responsibility
Average Resp. Approval Duration
Training (the request being approved for completing training)
Average Training Approval Duration -
Configuration - depending on whether its PRISM or iProcurement
Average Config. Approval Duration
Approved
Total Overall Duration
Security
Average Security Approval Duration
SOD
Avg SOD Approval Duration
So what I'm trying to do is to generate, some or all, of it using a SQL script.
One of my issues is that .. for a specific "Request Number" I'll often get redundant and conflicting data in the database.
Below is my query so far.
SELECT hur.reg_request_id AS "Request No",
RESPONSIBILITY_NAME AS "Module",
to_char(hur.creation_date, 'DD-Mon-YYYY HH24:MI:SS') AS "Submitted" ,
to_char(hur.last_update_date, 'DD-Mon-YYYY HH24:MI:SS') AS "Supervisor" ,
ROUND((hur.last_update_date - hur.creation_date), 3 ) ||
' days' AS "Avg Supervisor Appr Duration" ,
/* hura.creation_date AS "Responsibility" */,
NULL AS "Avg Resp Appr Duration", NULL AS "Training",
NULL AS "Avg Training Appr Duration" ,
hur.LAST_UPDATE_DATE AS "Security",
NULL AS "Avg Security Appr Duration",
NULL AS "SOD",
NULL AS "Average SOD Approval Duration" ,
NULL AS "Configuration",
NULL AS "Avg Config Appr Duration",
hurr.last_update_date AS "Approved",
ROUND( hurr.last_update_date - hur.creation_date, 2 )
AS "Total Overall Duration",
NULL AS "Notes"
FROM HHS_UMX_REG_SERVICES hur
JOIN fnd_responsibility_vl frt
ON (hur.responsibility_id = frt.responsibility_id and
hur.responsibility_application_id = frt.application_id)
JOIN
hhs_umx_reg_requests hurr ON
(hurr.reg_request_id = hur.reg_request_id )
/* JOIN hhs_umx_resp_activity hura */
left outer JOIN
hhs_umx_resp_activity
hura ON (hur.reg_request_id = hura.reg_request_id )--ADD ON
WHERE EXISTS (
SELECT NULL FROM hhs_umx_resp_activity hura
WHERE hura.created_by = hur.created_by
AND
hura.creation_date > hur.creation_date)
AND hur.reg_request_id IN
('263428', '263458', '263473',
'264717', '263402', '263404',
'262671', '263229', '263268')
ORDER BY hur.reg_request_id ASC
Here are the schemas :
HHS_UMX_RESP_ACTIVITY
HHS_UMX_REG_SERVICES
fnd_responsibility_vl
**hhs_umx_reg_requests **
thanks
As a simple solution you can just create rows that add the columns together in an SQL command. Something like "INSERT INTO TABLE ('REQ_NO', 'MODULE') VALUES (A2, B2)" etc. Then you can just use the excel function that copies it again and again for each row.
Another simple solution is to save the spreadsheet as CSV (play around with the exact CSV format to see what suits you) and then you might be able to just import it into your SQL table and play around there.
There are of course other more advanced solutions like TommCatt pointed out.
I have done this many times using Perl. There are packages for reading spreadsheets so just write the script to generate the insert statements needed. Then just write it into a nice .SQL text file which can then be executed by SQL Developer or whatever IDE you're using. Or just execute it directly from the Perl script.
It is hard to diagnose without sample tables (with only a few rows) reproducing the issue.
I think your duplicate data comes from a wrong join.
You could try to completely remove hhs_umx_resp_activity from the query (I see that you commented places where it is used).
Then if it continues it has to be related to the join on hhs_umx_reg_requests (you might be able to join an additional column or replace this join by something else, an outer apply for example).

SSAS Drillthrough in Excel

I have an issue when trying to drill through in excel. I have a fact table of employee terminations set up like the following. Each row is a termination.
For the drillthrough function in SSAS I am using ASSP.GetCustomDrilthroughMDX. Basically created a new action in the cube with the following action expression.
'call ASSP.ExecuteDrillthroughAndFixColumns("'
+ ASSP.GetCustomDrillthroughMDX("
[$Employee].[Employee ID]
, [$Employee].[Company Name]
, [$Employee].[Last Name]
, [$Employee].[First Name]
, [$Employee].[Start Date]
, [$Employee].[Last Day Worked]
, [$Employee].[HR Title]
, [$Employee].[Working Title]
, [$Employee].[HR Status]
, [$Employee].[Location ID]
, [$Department].[Department Number]
, [$Department].[Department Name]
, [$Employee].[Supervisor]
, [$Division].[Division Name]
")
+ '")'
The Condition is
[Measures].CurrentMember IS [Measures].[Involuntary] or
[Measures].CurrentMember IS [Measures].[Voluntary]
When I bring the Desired, Undesired, Voluntary, Involuntary and Other measures into a pivot table and try drill into say the Voluntary, I get the detail of the total amount of employees terminated, not just the Voluntary. For example if 6 employees were Voluntary, and 4 were Involuntary, and I drill into the voluntary I don't get the 6 employees, I get all 10 detail rows. I'm hoping I don't have to create a separate measure group for each type of termination. Any ideas?
So I figured this out.
In the Cube Design, I clicked on each measure in the Termination measure group and went to properties. Under properties expand Source. For NullProcessing property, set it to Preserve. This will preserve the null values in the underlying fact table. By default SSAS treats nulls as zero. Hope this helps someone else.