Forum Discussion

DemoFour's avatar
DemoFour
Icon for Continued Contributor rankContinued Contributor
6 years ago
Solved

Combine Years for Quarter

Appologies if this has been covered but I cant find anything to show how to do this when doing a search!

 

I have  Quarters that run in the following order:

Jan - March = Q4

April - June = Q1

July - September = Q2

October - December = Q3

 

I need to build a column that shows the years as follows, in order to filter the visuals by Quarter Year

Date                  Month           Quarter            Year                  QYear

01/01/17               1                       Q4                2017           2016 - 2017

01/01/18               1                       Q4                2018           2017 - 2018

01/01/19               1                       Q4                2019           2018 - 2019

 

Any help greratfully recived

  • Position of * 1 is wrong

    Year = ((FORMAT('Date'[Date],"YYYY") *1) -1) & "-"&FORMAT('Date'[Date],"YY")

    It should be after format close )

  •  

    For completeness of this thread, I solved the issues with a couple of columns for year quarter and FY quarter and then combined the year from the year coloumn to match them up in order to produce slicers.

     

    Year Q (Jan - Dec) = Yr Q = "Q" & INT (  FORMAT (  'DATE'[Date] , "q" )  ) 

     

    and

     

    FYQ (April - March UK) =

     

    FY Q =
    IF (
        'DATE'[Month Number] <= 3,
        "Q4",
        IF (
            'DATE'[Month Number] <= 6,
            "Q1",
            IF (
                'DATE'[Month Number] <= 9,
                "Q2",
                IF (
                    'DATE'[Month Number] <= 12,
                    "Q3"
                )
            )
        )
    )

     

    then used the following DAX

     

7 Replies

  • For Year

    Year = ((FORMAT('Calendar'[Date],"YYYY") *1) -1) & "-"&FORMAT('Calendar'[Date],"YY")
    • DemoFour's avatar
      DemoFour
      Icon for Continued Contributor rankContinued Contributor

      amitchandak 

      Thanks for the quick response, but the code whilst its on the lines I was working on (With format ),  is not quite right. Could you check please

      • amitchandak's avatar
        amitchandak
        Icon for Super User rankSuper User

        Position of * 1 is wrong

        Year = ((FORMAT('Date'[Date],"YYYY") *1) -1) & "-"&FORMAT('Date'[Date],"YY")

        It should be after format close )