Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Previous quarter

Our fiscal calendar starts in Jul, and now we are in the Q3. However, I have calculated the Q2 but now show the text somewhere at the bottom of the KPS stating this is Q2 data.   How should I poi...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous 

    I think your fiscal year is from July to June next year. Y

    our requirement is that when your maxdate in calendar is before the end of the qtr, it will show Qtr -1 and the year in Qtr -1. 

    Due to I don't know your data model, I build a sample to have a test.

    My Sample Table:

    Calendar = 
    VAR _DATE =
        ADDCOLUMNS (
            CALENDAR ( DATE ( 2020, 7, 01 ), TODAY() ),
            "Year", YEAR ( [Date] ),
            "Month", MONTH ( [Date] )
        )
    VAR _FYDate =
        ADDCOLUMNS (
            _DATE,
            "FY Year",
                IF ( [Month] < 7, [Year] - 1, [Year] ),
            "FY Qtr",
                SWITCH (
                    TRUE (),
                    [Month] IN { 7, 8, 9 }, 1,
                    [Month] IN { 10, 11, 12 }, 2,
                    [Month] IN { 1, 2, 3 }, 3,
                    4
                ),
            "FY End of Month",
                IF ( MOD ( [Month], 3 ) = 0, [Month], [Month] + 3 - MOD ( [Month], 3 ) )
        )
    RETURN
        _FYDate

    Add a calculated column in this table.

    FY End of Date = DATE([Year],[FY End of Month],IF([FY End of Month] in {3,12},31,30))

    Then I build a measure:

    Measure = 
    IF (
        MAX ( 'Calendar'[Date] ) < MAX ( 'Calendar'[FY End of Date] ),
        IF (
            MONTH ( MAX ( 'Calendar'[FY End of Date] ) ) = 3,
            "Qtr"
                & MAX ( 'Calendar'[FY Qtr] ) - 1 & " " & "Y"
                & FORMAT ( MAX ( 'Calendar'[Date] ), "YY" ) - 1,
            "Qtr"
                & MAX ( 'Calendar'[FY Qtr] ) - 1 & " " & "Y"
                & FORMAT ( MAX ( 'Calendar'[Date] ), "YY" )
        ),
        "Qtr" & MAX ( 'Calendar'[FY Qtr] ) & " " & "Y"
            & FORMAT ( MAX ( 'Calendar'[Date] ), "YY" )
    )

    Result is as below.

    Max date is 2021/1/11(Today)

    If Max date = 2021/4/01(QTR 3 gets over)

    You can download the pbix file from this link: Previous quarter

     

    Best Regards,

    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

  • amitchandak's avatar
    amitchandak
    5 years ago

    Anonymous , Make sure you FY end of Qtr , Qtr name or month name are there in calendar table and try measure like

    Measure =
    var _max = maxx(allselected(Data), Data[Date])
    return
    calculate(max('Date'[Qtr Name]), filter('Date',Data[Date] =_max))