Forum Discussion

ngutc's avatar
ngutc
Frequent Visitor
4 years ago
Solved

If date equals specific date than create a constant

Hello,    I'm working with a live database and i would like to create a measure where, if table(date[year]) equals 2005 then make a constant 5 else leave blank. If function does not take the date t...
  • tamerj1's avatar
    4 years ago

    Hi ngutc 
    Please use

    =
    SWITCH ( SELECTEDVALUE ( 'Date'[year] ), 2001, 3, 2003, 1, 2005, 5 )

    I noticed maybe you just want to take the right digit of odd years. If this is the case then use 

    =
    VAR CurrentYear =
        SELECTEDVALUE ( 'Date'[year] )
    RETURN
        IF ( ISODD ( CurrentYear ), VALUE ( RIGHT ( CurrentYear, 1 ) ) )