How to SUM grouped rows from a selected set of rows?

Hi everyone,

I'm stuck for a few days now and hoping that someone could help me with the following:
I have 3 related tables; CostGroup, Quotation (parent), and QuoItem (child).

QuoItem Table:
[ID_Quotation] is type Ref (is part of) ==> Linked to Quotation Table ==>[Related QuoItems]
[ID_CostGroup] is type Ref ==> Linked to CostGroup Table ==> [Related QuoItems]
VC: [_SUBTOTAL] = [Qty] * [Unit Price]

Quotation Table:
I have no problem obtaining each Quotation's Subtotal
[Subtotal] = SUM([Related QuoItems][_SUBTOTAL])

How do I obtain the total value of each group in QuoItem grouped by [ID_CostGroup] from each quotation?
I hope I have explained my situation clearly here. Thank you in advance.

CostGroup.pngQuotation.pngQuoItem.pngreport.png

0 2 288
2 REPLIES 2

Steve
Platinum 4
Platinum 4

This?

SUM(
  SELECT(
    [Related QuoItems][_SUBTOTAL],
    ([_THISROW].[ID_CostGroup] = [ID_CostGroup])
  )
)

Thank you @Steve for the pointer. I've tried that before, but the result is not what I expected.
The formula yields the SUM AGGREGATE of CostGroup from both quotations. My goal is to sum each CostGroup in each quotation. This is what I did.

I created a VC (_SUM_RELATED_COSTGROUP) in CostGroup Table with the following formula:

SUM(
SELECT(
[Related QuoItems][_SUBTOTAL],
([_THISROW].[ID] = [ID_CostGroup])
)

 Here's the screen capture of the 2 test records (quotations).
Quotation #1Quotation #1Quotation #2Quotation #2

Top Labels in this Space