Forum Discussion

FabioB7's avatar
FabioB7
New Member
1 year ago
Solved

YoY Comparison without date

Hi,   I am trying to create a YoY comparison based on fiscal quarter without having any calendar date, just pure fiscal quarter in text format   I have a bunch of quarters (Q324, Q424, Q125, Q225...
  • FBergamaschi's avatar
    FBergamaschi
    1 year ago

    We can solve this very easily, it is enough to create a calculate column in your fact table with the first date of each quarter, this column will be of type date (it will automatically get Date/Time Data type in Tabular, but you can convert it in Power BI Desktop (not on Power Query, it will not be visible there) to Date.

     

    Calculated column name and code:

    First Quarter Date =
    VAR _Year = INT ("20"&RIGHT(YourFactQuarterColumn, 2))

    VAR _MonthNr = 
    VAR _QuarterNr = LEFT ( YourFactQuarterColumn, 2)
    RETURN
    IF ( 
          QuarterNr = 1, 1,
          IF ( 
                 QuarterNr = 2, 4,
                 IF ( 
                       QuarterNr = 3, 7,
                       10
    )
    RETURN
    DATE ( _Year, _MonthNr, 1 )

     

    If this helped, please consider giving kudos and mark as a solution

     

    me in replies or I'll lose your thread

    Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

    Consider voting this Power BI idea

    Francesco Bergamaschi

    MBA, M.Eng, M.Econ, Professor of BI