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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
aanchalshah18
Helper I
Helper I

How can I access last 3 entries for an id?

I have 2 columns id and note_id, how can I access the last 3 note_id's for each id using Dax?

2 ACCEPTED SOLUTIONS
camargos88
Community Champion
Community Champion

Hi @aanchalshah18 ,

 

You can create a ranking column with values by id and filter.

 

Check this link: https://databear.com/how-to-use-the-dax-rankx-function-in-power-bi/

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

v-juanli-msft
Community Support
Community Support

Hi @aanchalshah18 

If you have data like this and want the result below:

Capture5.JPG

Please Create measures

Measure = RANKX(ALLEXCEPT('Table','Table'[id]),CALCULATE(SUM('Table'[Index])),,DESC,Dense)

 

Best Regards
Maggie
Community Support Team _ Maggie Li
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

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @aanchalshah18 

If you have data like this and want the result below:

Capture5.JPG

Please Create measures

Measure = RANKX(ALLEXCEPT('Table','Table'[id]),CALCULATE(SUM('Table'[Index])),,DESC,Dense)

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

 

Thanks for this, this is what I exactly need but can you tell me how you got the index column?

 

Anonymous
Not applicable

Hi,

 

You can choose the TOP option and I think that will do.

 

Best regards, 

Alin Oprita

amitchandak
Super User
Super User

If you need only three ID

rankx(all(table),table[note_id],,desc,dense)

If you need three with in Id, refer

https://www.sqlbi.com/articles/filtering-the-top-3-products-for-each-category-in-power-bi/

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin

camargos88
Community Champion
Community Champion

Hi @aanchalshah18 ,

 

You can create a ranking column with values by id and filter.

 

Check this link: https://databear.com/how-to-use-the-dax-rankx-function-in-power-bi/

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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