Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
CVkara92
New Member

Dynamic Rolling Quarter Rank

Would like to understand how dynamic rolling quarter rank written as DAX, I have date table and  want new column as below
and rank should change based on quarter/current year. Max 5 quarter of data can be display in visualization but should kind of dynamic rolling quarter data

QTRRank
Q1 20235
Q2 20234
Q3 20233
Q4 20232
Q1 20241

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1709964575253.png

 

Jihwan_Kim_1-1709964595423.png

 

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

RANK function (DAX) - DAX | Microsoft Learn

 

KEEPFILTERS function (DAX) - DAX | Microsoft Learn

 

Sales total: = 
SUM( Sales[sales] )

 

Recent 5 quarters rank: = 
VAR _today =
    TODAY ()
VAR _t =
    SUMMARIZE (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= _today ),
        'Calendar'[Year-Quarter]
    )
VAR _topfive =
    WINDOW ( 1, ABS, 5, ABS, _t, ORDERBY ( 'Calendar'[Year-Quarter], DESC ) )
RETURN
    RANK ( SKIP, _topfive, ORDERBY ( 'Calendar'[Year-Quarter], DESC ) )

 

Recent 5 quarters sales: = 
VAR _today =
    TODAY ()
VAR _t =
    SUMMARIZE (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= _today ),
        'Calendar'[Year-Quarter]
    )
VAR _topfive =
    WINDOW ( 1, ABS, 5, ABS, _t, ORDERBY ( 'Calendar'[Year-Quarter], DESC ) )
RETURN
    CALCULATE ( [Sales total:], KEEPFILTERS ( _topfive ) )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

2 REPLIES 2
CVkara92
New Member

Thank you , it worked

Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1709964575253.png

 

Jihwan_Kim_1-1709964595423.png

 

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

RANK function (DAX) - DAX | Microsoft Learn

 

KEEPFILTERS function (DAX) - DAX | Microsoft Learn

 

Sales total: = 
SUM( Sales[sales] )

 

Recent 5 quarters rank: = 
VAR _today =
    TODAY ()
VAR _t =
    SUMMARIZE (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= _today ),
        'Calendar'[Year-Quarter]
    )
VAR _topfive =
    WINDOW ( 1, ABS, 5, ABS, _t, ORDERBY ( 'Calendar'[Year-Quarter], DESC ) )
RETURN
    RANK ( SKIP, _topfive, ORDERBY ( 'Calendar'[Year-Quarter], DESC ) )

 

Recent 5 quarters sales: = 
VAR _today =
    TODAY ()
VAR _t =
    SUMMARIZE (
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= _today ),
        'Calendar'[Year-Quarter]
    )
VAR _topfive =
    WINDOW ( 1, ABS, 5, ABS, _t, ORDERBY ( 'Calendar'[Year-Quarter], DESC ) )
RETURN
    CALCULATE ( [Sales total:], KEEPFILTERS ( _topfive ) )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.