Using sumIf inside an ifelse statement

I want to use a sumIf inside an ifelse to do something like this:

ifelse(
    {country}="US", sumif({amount}, {dimension}="Type 1"),
    {country}="CA", sumif({amount}, {dimension}="Type 2"),
    NULL)

However, when I try this, I get errors. I think it’s because I can’t use a sumIf inside an ifelse function. Is there any other way to accomplish the same? Thanks in advance!

Hi,

have you tried it. :slight_smile:

sum(ifelse(
{country}=“US”, sumif({amount}, {dimension}=“Type 1”),
{country}=“CA”, sumif({amount}, {dimension}=“Type 2”),
NULL)(

I tried adding

sum( ifelse(
{country}=“US”, sumif({amount}, {dimension}=“Type 1”),
{country}=“CA”, sumif({amount}, {dimension}=“Type 2”),
NULL))

but the error persists.

Hi,

please try this:

sum(
ifelse({country}=“US” AND {dimension}=“Type 1”,{amount},
ifelse({country}=“CA” AND {dimension}=“Type 2”,{amount},NULL))
)