简体   繁体   中英

Excel formula to calculate values based on other cells

I've got the following table: 在此处输入图像描述

I'm using the following formula in column F to get the sum of the values in column E : =SUMIFS(E:E,C:C,LEFT(TRIM(RIGHT([@[Object Name]],LEN([@[Object Name]])-FIND("=",[@[Object Name]]))),4),A:A,INT([@[Result Time]])) but it doesn't seem to work.

Evaluating the formula gives me the following result: 在此处输入图像描述

Can someone please take a took at the for

You are looking for an object name of "T054", when they all appear to be "CELL=T054CID"... so no results are being returned.

What exactly is it you are trying to do?

Is there any reason you cannot just do:

=SUMIFS([3G_Traffic_CS],[Object Name],[@[Object Name]],[Result Time],[@[Result Time]])

在此处输入图像描述

You will also notice that I am referencing just the column cells within the table, rather than the entire column. This is more efficient and will prevent any extra values which appear under the table being counted (unlikely but not impossible).

ALTERNATIVE (Using a Helper Column)

Add a helper column which contains a trimmed value of the Object Name and compare to that:

=SUMIFS([3G_Traffic_CS],[Trimmed Object Name],[@[Trimmed Object Name]],[Result Time],[@[Result Time]])

在此处输入图像描述

ANOTHER ALTERNATIVE (Using FIND and SUMPRODUCT )

If you want to include any Object Name which CONTAINS your trimmed value, you can do this using the FIND function with SUMPRODUCT :

=SUMPRODUCT(
    ([Result Time]=[@[Result Time]])*
    (ISNUMBER(
        FIND(LEFT(TRIM(RIGHT([@[Object Name]],LEN([@[Object Name]])-FIND("=",[@[Object Name]]))),4),
            [Object Name]
        )
    ))*
    [3G_Traffic_CS]
)

在此处输入图像描述

YET ANOTHER ALTERNATIVE (Using a Wildcard as per @Jvdv's comment)

Again, this assumes that you want to include all Object Names which CONTAIN your trimmed site ID. Simply add a "*" to the start and end of your trimmed Object Name.

=SUMIFS([3G_Traffic_CS],
    [Object Name],
    CONCAT("*",
        LEFT(TRIM(RIGHT([@[Object Name]],LEN([@[Object Name]])-FIND("=",[@[Object Name]]))),4),
        "*"
    ),
    [Result Time],
    INT([@[Result Time]])
)

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM