Forum Discussion
Display first 5 rows using DAX in Power BI
- 1 year ago
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.
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:
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'.