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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
adii
Helper I
Helper I

How to tak 3 recent row from table in DAX

Hello , 

I'm looking solve my problem .

I have a table with column A with datetime 

Column A 
2024-01-11 10:54:55

2024-01-11 10:54:33

2024-01-11 10:51:00

2024-01-11 10:51:00

2024-01-11 10:50:23

 

Column B

123

175

155

122

125

 

i would like recive table ( Column A and B) with first 4 row based on Datetime (Ascending)

 

which function I should use ? 
I thought about RANKX , but that function rankx needs measure 

 

thanks 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @adii ,

 

Are you referring to finding the ordering of [column A] based on the grouping of [column C]?

You can use the following calculated columns:

Rank =
RANKX(
    FILTER(
        ALL('Table'),'Table'[ColumnC]=EARLIER('Table'[ColumnC])),'Table'[ColumnA],,DESC,Dense)

vyangliumsft_0-1705314191969.png

 

Best Regards,

Liu Yang

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

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi  @adii ,

 

Are you referring to finding the ordering of [column A] based on the grouping of [column C]?

You can use the following calculated columns:

Rank =
RANKX(
    FILTER(
        ALL('Table'),'Table'[ColumnC]=EARLIER('Table'[ColumnC])),'Table'[ColumnA],,DESC,Dense)

vyangliumsft_0-1705314191969.png

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

Hi  @adii ,

 

Here are the steps you can follow:

1. Create calculated column.

Rank =
RANKX(
    'Table','Table'[ColumnA],,DESC,Dense)

vyangliumsft_0-1705034547904.png

2. Create calculated table.

Table 2 =
FILTER(
    'Table',
[Rank]<=3)

3. Result:

vyangliumsft_1-1705034547905.png

 

Best Regards,

Liu Yang

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

Perfect it's working thanks . 
so can you help me in a little more tricky example . Now I need do the same like above but I got extra column C with date (year-month-day) and a would like make ranking for each day separately.

? I'n trying use 

calculate( Rank, All(table[column C]) but doesn't work .. 

 

adii
Helper I
Helper I

What you think about add column with numer increment ? Start from 1 to 4 

gmachowiak
Frequent Visitor

I'd use TOPN fucntion:

    TOPN(
        3,
        'Table',
        'Table'[Column1],
        ASC
    )

Doesn't work ,  it's multiply values, should be scalar  

lbendlin
Super User
Super User

use the WINDOW function with relative addressing from -3 to -1

Doesn't work 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors