Forum Discussion

PeterParker's avatar
PeterParker
Helper I
4 years ago
Solved

Special Timeperiod

Hello everyone, i need your help. Some key figures have to be calculated every quarter, at first this sounds simple. However, values ​​from the past 3 quarters (one year in total) should be output i...
  • v-yanjiang-msft's avatar
    v-yanjiang-msft
    4 years ago

    Hi PeterParker ,

    I haven't created a calendar, here's my solution.

    1.Create three columns.

    YearQuarter = FORMAT('Table'[Date],"YYYY-Q")
    Rank = RANKX('Table','Table'[YearQuarter],,ASC,Dense)
    Quarter = 
    VAR _BeginnQrt =
        DATEADD ( 'Table'[Date], -3, QUARTER )
    VAR _Spezial_Qrt =
        "Qtr" & FORMAT ( _BeginnQrt, "Q YYYY" ) & " - Qtr"
            & FORMAT ( 'Table'[Date], "Q YYYY" )
    RETURN
        IF ( ISBLANK ( _BeginnQrt ), BLANK (), _Spezial_Qrt )
    

    2.Create a measure.

    Sum value = 
    SUMX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Rank]
                IN {
                    MAX ( 'Table'[Rank] ),
                    MAX ( 'Table'[Rank] ) - 1,
                    MAX ( 'Table'[Rank] ) - 2,
                    MAX ( 'Table'[Rank] ) - 3
                }
        ),
        'Table'[Value]
    )
    

    3.Get the expected result.

     

    I attach my sample below for reference.

    Best Regards,
    Community Support Team _ kalyj

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