Summing Rows that meet certain conditions

Hey Everyone,

I have a table full of rows and Im trying to get the sum of rows that are related to other rows.

This is my formula right now.

SUM(
SELECT(
Wrapper Leg 1[Leg #1 Counter],
AND(
([Date] = This_[Date]),
([CustomerType] = [CustomerType])
),TRUE
)
)

Im trying to get the sum of rows from the Leg 1 counter that have the same Date and customer Type.

Its either adding all the rows together or just throwing me errors. Ive tried many things.

Solved Solved
0 6 420
1 ACCEPTED SOLUTION

Because of a quirk with the is-equal-to operator (=), it may make a difference which operand is on the left and which is on the right. Try this:

SUM(
SELECT(
Wrapper Leg 1[Leg #1 Counter],
AND(
[_THISROW].[Date] = [Date],
[_THISROW].[CustomerType] = [CustomerType]
)
)
)

View solution in original post

6 REPLIES 6

Steve
Platinum 4
Platinum 4

Ive also tried this,

This doesnโ€™t work either, still adding up all rows for some items, and none for others.

SUM(
SELECT(
Wrapper Leg 1[Leg #1 Counter],
AND(
[Date] = [_THISROW].[Date],
[CustomerType] = [_THISROW].[CustomerType]
)
)
)

Because of a quirk with the is-equal-to operator (=), it may make a difference which operand is on the left and which is on the right. Try this:

SUM(
SELECT(
Wrapper Leg 1[Leg #1 Counter],
AND(
[_THISROW].[Date] = [Date],
[_THISROW].[CustomerType] = [CustomerType]
)
)
)

Same Results. :(.

Adding all rows for some items and giving an output of 0 for others.

Are you willing to share a screenshot of a sample of the Wrapper Leg 1 spreadsheet?

Its working Steve.!! , Cant believe it but just realized I was calling the wrong table. Thanks for pointing that out. man.

Top Labels in this Space