Forum Discussion
ngutc
4 years agoFrequent Visitor
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...
- 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 ) ) )
tamerj1
Community Champion
4 years agoHi 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 ) ) )- ngutc4 years agoFrequent Visitor
Thank you a lot! It worked with the switch function! I actaully wanted the constants for every 5 years, not for the odd ones.
- tamerj14 years ago
Community Champion
Then this one
= VAR CurrentYear = SELECTEDVALUE ( 'Date'[year] ) RETURN IF ( MOD ( CurrentYear, 5 ) = 0, VALUE ( RIGHT ( CurrentYear, 1 ) ) )- ngutc4 years agoFrequent Visitor
what i get is this
2000 0 2001 2002 2003 2004 2005 5 2006 2007 2008 2009 2010 0
I want to be able to declare for each five years a different constant.