Forum Discussion

YusufHabib's avatar
YusufHabib
New Member
5 years ago
Solved

Converting quarters & years into numerical values

I am trying to write a simple DAX query to convert a time series (written as text) into numerical equivalent in order to use in power BI charts. The time series values are in the form of "PD_Q1", "P...
  • VahidDM's avatar
    VahidDM
    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!!