Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group/Sort on Formula Field Containing Sums

Status
Not open for further replies.

skystar70

Technical User
Nov 3, 2006
40
US
Hi. Complex situation here (for me anyway). :)

I have a report of project names and costs for each project, broken out by expense total and capital total, then project total. I need to sort the report by project total high to low.

Here is why it is so complex: The records are summed at a group level because there are multiple records for each project where costs are concerned.
To complicate matters furhter, there are many different fields, from 2 different tables that are summed to get the expense total and same with the capital total and of course, project total.

When I try to create a group on the summed project total, that formula/field is not available. The only fields that come close to what I need are the sums of each table fields, which only gives me part of the picture. I end up with odd records that are not sorted properly, because their data comes from the OTHER table that is not grouped/sorted.

So, here is the formula that I want to sort on:

{@OL Budget Screen} + {@Hdwe Budget Screen} + {@Sftw Budget Screen} +
{@Telecom Budget Screen} + {@Travel Budget Screen} +
{@Train Budget Screen} + {@Other Budget Screen} + {@Cap Budget Screen} +
Sum ({@All Expense Target}, {planning_entity_7.short_name}) +
Sum ({@Capital Target}, {planning_entity_7.short_name})

Here is the @OL Budget Screen formula:

if isnull({custom_data.tenestol}) then 0
else {custom_data.tenestol}


The next 7 formulas are the same idea as this one. (Anything with "Budget Screen" in the total.)

The @All Expense Target formula (which is summed):

if {vw_ace_rpt_budget_data.period_finish_yearmo} startswith "2010" and
{vw_ace_rpt_budget_data.version_code} = "207707" and
{vw_ace_rpt_budget_data.cost_father_code} in ["192","207588"] and
not isnull ({vw_ace_rpt_budget_data.value}) then
{vw_ace_rpt_budget_data.value} else 0

@Capital Target is similar.

I'm not sure if I've explained this adequately or left out any vital information. Any help you can provide would be great.

Thanks, Skystar
 
In order to activate the group sort feature, you must first insert a summary on the formula. If the formula is not available for inserting a summary, you cannot group sort by it.

Is the formula you show the "summed project total" itself or do you still need to sum the formula before sorting?

What version of CR are you using? If you are able to use a SQL expression to return the two sums, you should be able to move forward.

-LB
 
The formula is not available for inserting a summary. The formula is the summed project total already. If I could just sort on this formula field, life would be grand. So far, I have been doing all of my sorts for this report by inserting groups, but these have been on single database fields.

I am version 9.2. I don't know much about SQL unfortunately, so I don't know if I could use it.

Skystar.
 
If you go into the field explorer, do you see SQL Expression Field listed below Formula Field?

-LB
 
Can you please paste in your SQL query from database->show SQL query?

-LB
 
SELECT "vw_ACE_Work_Data"."work_title", "vw_ACE_Work_Data"."work_id",
"vw_ACE_Work_Data"."work_depth", "custom_data"."acecmpldt",
"custom_data"."planenddate", "vw_ACE_Work_Data"."ace_portfolio",
"st_wbs99"."description", "vw_ACE_Work_Data"."ace_execution_stage",
"custom_data"."planstart", "custom_data"."actcompdate",
"custom_data"."tenestol", "custom_data"."tenesthdw",
"custom_data"."tenesttrvl", "custom_data"."tenesttrain",
"custom_data"."tenestcap", "custom_data"."tenestsftw",
"custom_data"."tenesttel", "custom_data"."tenestother",
"st_wbs125"."description", "planning_entity_7"."short_name",
"vw_ace_rpt_budget_data"."period_finish_yearmo",
"vw_ace_rpt_budget_data"."version_code",
"vw_ace_rpt_budget_data"."cost_father_code",
"vw_ace_rpt_budget_data"."value", "s_work"."structure_name",
"s_work"."extract_id", "vw_ace_rpt_budget_data"."cost_code",
"custom_data"."ace_business_pri", "s_work"."structure_code",
"s_work"."ppl", "st_wbs114"."description", "st_wbs58"."description",
"st_wbs101"."description", "custom_data"."s1"

FROM {oj (((((("PVPROD9"."ip"."sss" "s_work" INNER JOIN
(("PVPROD9"."ip"."vw_ACE_Work_Data" "vw_ACE_Work_Data" INNER JOIN
"PVPROD9"."ip"."custom_data" "custom_data" ON
"vw_ACE_Work_Data"."planning_code"="custom_data"."planning_code") INNER
JOIN "PVPROD9"."ip"."planning_entity" "planning_entity_7" ON
"custom_data"."planning_code"="planning_entity_7"."planning_code") ON
"s_work"."structure_code"="planning_entity_7"."planning_code") INNER JOIN
"PVPROD9"."ip"."vw_ace_rpt_budget_data" "vw_ace_rpt_budget_data" ON
"s_work"."structure_code"="vw_ace_rpt_budget_data"."budget_unit_code")
LEFT OUTER JOIN "PVPROD9"."ip"."structure" "st_wbs99" ON
"planning_entity_7"."code99"="st_wbs99"."structure_code") LEFT OUTER JOIN
"PVPROD9"."ip"."structure" "st_wbs125" ON
"planning_entity_7"."code125"="st_wbs125"."structure_code") LEFT OUTER
JOIN "PVPROD9"."ip"."structure" "st_wbs114" ON
"planning_entity_7"."code114"="st_wbs114"."structure_code") LEFT OUTER
JOIN "PVPROD9"."ip"."structure" "st_wbs58" ON
"planning_entity_7"."code58"="st_wbs58"."structure_code") LEFT OUTER JOIN
"PVPROD9"."ip"."structure" "st_wbs101" ON
"planning_entity_7"."code101"="st_wbs101"."structure_code"}

WHERE ("s_work"."extract_id"='20050707112136_pvmaster' AND
"s_work"."structure_name"='$Plan' AND "vw_ACE_Work_Data"."work_depth"=7
AND "st_wbs125"."description"='Discretionary' AND
"vw_ACE_Work_Data"."ace_portfolio"<>'Ongoing Support Activities' AND
("vw_ACE_Work_Data"."ace_execution_stage"='Deploying' OR
"vw_ACE_Work_Data"."ace_execution_stage"='Executing' OR
"vw_ACE_Work_Data"."ace_execution_stage"='Initiating' OR
"vw_ACE_Work_Data"."ace_execution_stage"='On hold' OR
"vw_ACE_Work_Data"."ace_execution_stage"='Planning') AND
("vw_ace_rpt_budget_data"."version_code"='207707' OR
"vw_ace_rpt_budget_data"."version_code"='xxx') AND
"s_work"."structure_code"="s_work"."ppl" AND "custom_data"."planstart"<{ts
'2010-01-01 00:00:00'} OR "s_work"."extract_id"='20050707112136_pvmaster'
AND "s_work"."structure_name"='$Plan' AND
"vw_ACE_Work_Data"."work_depth"=7 AND
"st_wbs125"."description"='Discretionary' AND
"vw_ACE_Work_Data"."ace_portfolio"<>'Ongoing Support Activities' AND
("vw_ACE_Work_Data"."ace_execution_stage"='Deploying' OR
"vw_ACE_Work_Data"."ace_execution_stage"='Executing' OR
"vw_ACE_Work_Data"."ace_execution_stage"='Initiating' OR
"vw_ACE_Work_Data"."ace_execution_stage"='On hold' OR
"vw_ACE_Work_Data"."ace_execution_stage"='Planning') AND
("vw_ace_rpt_budget_data"."version_code"='207707' OR
"vw_ace_rpt_budget_data"."version_code"='xxx') AND
"s_work"."structure_code"="s_work"."ppl" AND "custom_data"."s1"='Y' AND
"custom_data"."planstart"<{ts '2011-01-01 00:00:00'})
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top