Power BI Exchange

Please login or click SIGN UP FOR FREE to create your PowerBIUG account to join this user group.
 View Only

Rolling 12 month sales dax

  • 1.  Rolling 12 month sales dax

    Silver Contributor
    Posted Jan 04, 2022 07:13 AM
    Hi guys,
    I have a report where i want to see the rolling 12 month sales which can be seen as below
    The slicer when selected for 2021 it should show the last 12 month sales, rather it shows only 2021 sales.
    The measure for sales amount last 2 month is
    Sales amount 12 month =
    ---------------------------------------------------------
    VAR _selectedAltYear =
    SELECTEDVALUE( 'To Year'[Year Number])
    -----------------------------------------------------
    //new date table
    VAR __rlvntDateTable =
    CALCULATETABLE(
    'Date',
    FILTER('Date','Date'[Date]>= edate([Max Date of To Year],-12) && 'Date'[Date]<= [Max Date of To Year])
    )
    ---------------------------------------------------------
    VAR _altsalesamount =
    CALCULATE( [Sales Amount], __rlvntDateTable )
    RETURN
    _altsalesamount
    Is there a way to get this result.

    Also another issue is that when 2022 is selected in the slicer, it shows from jan 2022 to jan 2021 which is 13 months sales. And also jan 2022 is not a completed month, is there a way to resolve this issue.
    PS.-To Year table used in the measure is an independent table not having any relations with any other dim and facts


    ------------------------------
    Anu Radha
    98402454127
    ------------------------------