Forum Discussion

Joe89's avatar
Joe89
Regular Visitor
2 years ago
Solved

New Column based on Condition and Calculation

Hello,   I am trying to create a line grap showing a "Value" per "Phase" and respective limits. the limits are being calculated based on the previous phase value. The value resulting out of the pha...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi PhilipTreacy ,thanks for the quick reply, I'll add more.

    Hi Joe89 ,

    The Table data is shown below:

    Use the following DAX expression to create columns

    Low Limit = 
    VAR _phase = [Phase]
    VAR _Project = [Project]
    VAR _table = ALL('Table')
    VAR _result = 
    SWITCH(TRUE(),
    _phase = 1 , [Value] * 0,
    _phase = 2 , MAXX(FILTER(_table,[Project] = _Project && [Phase] = _phase - 1 ),[Value]) * 0.5,
    _phase = 3 , MAXX(FILTER(_table,[Project] = _Project && [Phase] = _phase - 1 ),[Value]) * 0.7,
    _phase = 4 , MAXX(FILTER(_table,[Project] = _Project && [Phase] = _phase - 1 ),[Value]) * 0.9
    )
    RETURN _result
    Upper Limit = 
    VAR _phase = [Phase]
    VAR _Project = [Project]
    VAR _table = ALL('Table')
    VAR _result = 
    SWITCH(TRUE(),
    _phase = 1 , [Value] * 2,
    _phase = 2 , MAXX(FILTER(_table,[Project] = _Project && [Phase] = _phase - 1 ),[Value]) * 1.5,
    _phase = 3 , MAXX(FILTER(_table,[Project] = _Project && [Phase] = _phase - 1 ),[Value]) * 1.3,
    _phase = 4 , MAXX(FILTER(_table,[Project] = _Project && [Phase] = _phase - 1 ),[Value]) * 1.1
    )
    RETURN _result

    Final output

     

    Best Regards,
    Wenbin Zhou