Forum Discussion
Converting quarters & years into numerical values
- 5 years ago
Oh, Do you want to add a calculated column?
You can use my codes as a Measure, not a new Column.
If you want a column, use this code:
Time in Years = Var _Len = LEN(Base[Time] )-4 RETURN IF( CONTAINSSTRING(Base[Time],"Q") , RIGHT(Base[Time],_Len)/4, IF( CONTAINSSTRING(Base[Time],"Y") , RIGHT(Base[Time],_Len)/1 ) )If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Really appreciate your prompt replies.
I pasted the code and recieved error 'Expressions that yield variant data-type cannot be used to define calculated columns'.
Oh, Do you want to add a calculated column?
You can use my codes as a Measure, not a new Column.
If you want a column, use this code:
Time in Years =
Var _Len = LEN(Base[Time] )-4
RETURN
IF(
CONTAINSSTRING(Base[Time],"Q") , RIGHT(Base[Time],_Len)/4,
IF(
CONTAINSSTRING(Base[Time],"Y") , RIGHT(Base[Time],_Len)/1
)
)
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
- YusufHabib5 years agoNew Member
Thanks! I didn't realize that columns and measures have differences in formula.
It works now.