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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
amolgharge
New Member

Display first 5 rows using DAX in Power BI

 

I am new to Power BI. I have a table named 'Mobile Sales Data' having two columns 'Sales Date' and 'Total Sale' as shown here. Its date wise sale amount.

I want to show -

1. First 5 rows i.e. 09,09,09,10,10 October 2021 records ( from sale amount 61,048.20 to 1.27.819.90)  datewise with Total Sale. I tried a lot but not getting required output. Kindly  provide me DAX .

Thank You.

 


Sale Data.jpg

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@amolgharge 

If you want to create a measure to filter the first 5 rows in a visual, you can use the following DAX formula:

DAX
First5RowsMeasure =
IF(
RANKX(
ALL('Mobile Sales Data'),
'Mobile Sales Data'[Sales Date],
,
ASC
) <= 5,
1,
0
)

 

You can then use this measure in your visual filters to show only the rows where First5RowsMeasure equals 1.

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

5 REPLIES 5
V-yubandi-msft
Community Support
Community Support

Hi @amolgharge ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you.

V-yubandi-msft
Community Support
Community Support

Hi @amolgharge ,

We noticed we haven't received a response from you yet, so we wanted to follow up and ensure the solution we provided addressed your issue. If you require any further assistance or have additional questions, please let us know.

Your feedback is valuable to us, and we look forward to hearing from you soon.

V-yubandi-msft
Community Support
Community Support

Hi @amolgharge ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

V-yubandi-msft
Community Support
Community Support

Hi @amolgharge ,

Thank you for reaching out to the Microsoft Fabric Community.

1.  Load your data into Power BI.

2. Add Index Column
→ Go to Transform Data → Add Column → Index Column → From 1

3. Create Calculated Column in Data View

DAX:

ShowFirst5 = IF('Mobile Sales Data'[Index] <= 5, 1, 0)

4.  Add a Table Visual
→ Add Sales Date and Total Sale

5. In the Filters on this visual pane:

Drag ShowFirst5 into the filter area.

Set the filter to "is 1".

 

FYI:

Vyubandimsft_0-1744561314385.png

 

If my response solved your query, please mark it as the Accepted solution to help others find it easily.

And if my answer was helpful, I'd really appreciate a 'Kudos'.

bhanu_gautam
Super User
Super User

@amolgharge 

If you want to create a measure to filter the first 5 rows in a visual, you can use the following DAX formula:

DAX
First5RowsMeasure =
IF(
RANKX(
ALL('Mobile Sales Data'),
'Mobile Sales Data'[Sales Date],
,
ASC
) <= 5,
1,
0
)

 

You can then use this measure in your visual filters to show only the rows where First5RowsMeasure equals 1.

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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