Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Create a calculated column with condition

Good afternoon   I want to create a calculated column as a "Flag" with just 0's and 1's if the units where less than projected. When doing so, I get the addition of all rows where the condition was...
  • smpa01's avatar
    5 years ago

    Anonymous  try this as a calculated column

     

    flag =
    VAR _units =
        CALCULATE ( SUM ( t2[UNITS] ), ALLEXCEPT ( t2, t2[ID] ) )
    VAR _proj =
        CALCULATE ( SUM ( t2[PROJECTED] ), ALLEXCEPT ( t2, t2[ID] ) )
    RETURN
        IF ( _units < _proj, 1, 0 )