Forum Discussion

AllanBerces's avatar
AllanBerces
Post Prodigy
1 year ago
Solved

IF

Hi to all, 

Can someone help me to edit my measure to add IF condition from the current measure, I have a table with column of Week no. What i need is if the value is lessthan this week make it zero.

 

_5 Delta PY Line Negative AC = IF([_5 Delta PY] <0, [_5 Delta PY Line] + [_5 Delta PY], BLANK())
 
Thank you
  • Hi AllanBerces ,

    You can achieve the desired result by using this DAX:

    _5 Delta PY Line Negative AC =
    VAR CurrentWeek = MAX(DateTable[Week No])  -- Get the current week number
    RETURN
        IF(
            MAX(DateTable[Week No]) < CurrentWeek,  -- Check if the week is less than the current week
            0,  -- Set the value to zero
            IF(
                [_5 Delta PY] < 0, 
                [_5 Delta PY Line] + [_5 Delta PY], 
                BLANK()
            )
        )
    

3 Replies

  • Uzi2019's avatar
    Uzi2019
    Community Champion

    Hi AllanBerces 

     

    Can you share the sample data and expected output??

     

    would be better for us to understand your scenario.

     

     

  • Hi AllanBerces ,

    You can achieve the desired result by using this DAX:

    _5 Delta PY Line Negative AC =
    VAR CurrentWeek = MAX(DateTable[Week No])  -- Get the current week number
    RETURN
        IF(
            MAX(DateTable[Week No]) < CurrentWeek,  -- Check if the week is less than the current week
            0,  -- Set the value to zero
            IF(
                [_5 Delta PY] < 0, 
                [_5 Delta PY Line] + [_5 Delta PY], 
                BLANK()
            )
        )