Forum Discussion

brief001's avatar
brief001
Helper II
3 years ago
Solved

Calculated column with sum as function

I'm looking for a formula that uses sums as logic that we know in Excel. I want to add a calculated column (orange) in the table below. That sums values of column value if the column values of date a...
  • daXtreme's avatar
    3 years ago

    Hint: You should never use EARLIER. There is a much better alternative and it's called VARIABLES.

    // This is the formula for your column...
    
    [Total Value] =
    var CurrentDate = YourTable[Date]
    var CurrentColor = YourTable[Color]
    var Output =
        sumx(
            filter(
                YourTable,
                YourTable[Date] = CurrentDate
                &&
                YourTable[Color] = CurrentColor
            ),
            YourTable[Value]
        )
    return
        Output