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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to get last 4 measures from column

Hello guys,

 

I need to get last 4 measures from column (measures) by date (there could be more measures in one day).

 

Can anybody help me how to use DAX to get it  ?

 

Thank you in advance

1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can roughly understand your requirement, you want to filter the data table to show you the trend for the last 4 values and not use the Top N function, right? I think you can try this method:

This is the test data I created based on your description:

vrobertqmsft_0-1642477082686.png

 

You can create the rank column like this:

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

Then you can create a calculated table like this:

last 4 values =

SELECTCOLUMNS(FILTER('Table','Table'[Rank]<=4),"Date",'Table'[Date],"measurements",'Table'[measurements])

 

vrobertqmsft_1-1642477082693.png

 

And you can create a line chart to place it like this to get what you want.

vrobertqmsft_2-1642477082714.png

 

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can roughly understand your requirement, you want to filter the data table to show you the trend for the last 4 values and not use the Top N function, right? I think you can try this method:

This is the test data I created based on your description:

vrobertqmsft_0-1642477082686.png

 

You can create the rank column like this:

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

Then you can create a calculated table like this:

last 4 values =

SELECTCOLUMNS(FILTER('Table','Table'[Rank]<=4),"Date",'Table'[Date],"measurements",'Table'[measurements])

 

vrobertqmsft_1-1642477082693.png

 

And you can create a line chart to place it like this to get what you want.

vrobertqmsft_2-1642477082714.png

 

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

amitchandak
Super User
Super User

@Anonymous , Last for measures?

 

if you need rolling

Rolling 4= CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-4,Day))

 

The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hello @amitchandak ,

I have column with measurements (numbers between 0 -5) which are each day updated with new neasurements. I have to add Sparkline to my table which show me trend for last 4 values. I can't use filter Top N, because I'm using rank function.

I need probably create a new value(column) where I will have always only last 4 measurements from column "measurements".

I hope I make it more clear now.

Thank you in advance

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.