select top 5 accounts in each region in an month per sales My data is in table Sales

ACCT_ID |REGION | DATE_FILTER | SALES
1001    | TEXAS |  2018-01    | 10
1002    | DENV  |  2018-01    | 30
1004    | WDC   |  2018-01    | 50
1001    | TEXAS |  2018-02    | 500
1002    | DENV  |  2018-02    | 300
1004    | WDC   |  2018-02    | 120


I want to find out rank of each account in a district per month by sales my output will look like 

ACCT_ID |REGION | DATE_FILTER | SALES   | Rank
1001    | TEXAS |  2018-01    | 10      |3
1002    | DENV  |  2018-01    | 30      |2
1004    | WDC   |  2018-01    | 50      |1
1001    | TEXAS |  2018-02    | 500     |1
1002    | DENV  |  2018-02    | 300     |2
1004    | WDC   |  2018-02    | 120     |3


I am using Mysql 5.7 version, I have tried below

SELECT
        ACCT_ID ,REGION,SALES,DATE_FILTER,n RANK
    FROM
      ( SELECT  @prev := '', @n := 0 ) init
    JOIN
      ( SELECT  @n := if(DATE_FILTER != @prev_rpt_mnth and REGION != @prev_reg, 1, @n + 1) AS n, /* HERE I AM USING TWO COLUMNS TO GROUP BY */
                @prev_rpt_mnth := DATE_FILTER,
                @prev_reg := REGION
                ACCT_ID ,REGION,SALES,DATE_FILTER,UNITS
            FROM  SALES
            ORDER BY
                DATE_FILTER,REGION ASC,
                UNITS DESC
            LIMIT 999999
      ) x
    WHERE  n &lt;= 5
    ORDER BY  DATE_FILTER,REGION, n;


I am getting duplicates as well it not properly ranking based on sales. Where I am going wrong and is there any other efficient way.
You must init ALL variables on the level where they are used. In your case - in subquery data source. - akina