Forum Discussion

awitt's avatar
awitt
Helper III
7 years ago
Solved

Column calculation based on text string

Needing to create a calculated column that takes into account several other columns as well. A sample of my data is below.   Basically I need to take the revenue for the rows with an item ver...
  • v-lili6-msft's avatar
    v-lili6-msft
    7 years ago

    HI, awitt 

    You could use this formula as below:

    Column = 
    IF (
        Sheet2[Item Version] <> "S",
        CALCULATE (
            SUM ( Sheet2[Per Item Revenue] ),
            FILTER (
                Sheet2,
                Sheet2[Order #] = EARLIER ( Sheet2[Order #] )
                    && Sheet2[Item Version] = "S"
            )
        )
            / CALCULATE (
                SUM ( Sheet2[Quantity] ),
                FILTER (
                    Sheet2,
                    Sheet2[Order #] = EARLIER ( Sheet2[Order #] )
                        && Sheet2[Item Version] <> "S"
                )
            )
    )

    Result:

     

    Best Regards,

    Lin