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

Top N rows and SUm

Team - I have table of 100 rows as below

Need a Measure to add top 3 rows.. only on population (total = 6)

I googled but could not find any 

CountryPopulation
aa2
bb3
cc1
dd10
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below.

The top 3 sum is depending on the index of the country.

 

Jihwan_Kim_0-1707474771356.png

 

Jihwan_Kim_1-1707474890818.png

 

 

Population measure: = 
SUM( Data[Population] )

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

expected result measure: =
CALCULATE (
    [Population measure:],
    KEEPFILTERS (
        WINDOW (
            1,
            ABS,
            3,
            ABS,
            ALL ( Data[Country Index], Data[Country] ),
            ORDERBY ( Data[Country Index], ASC )
        )
    )
)

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below.

The top 3 sum is depending on the index of the country.

 

Jihwan_Kim_0-1707474771356.png

 

Jihwan_Kim_1-1707474890818.png

 

 

Population measure: = 
SUM( Data[Population] )

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

expected result measure: =
CALCULATE (
    [Population measure:],
    KEEPFILTERS (
        WINDOW (
            1,
            ABS,
            3,
            ABS,
            ALL ( Data[Country Index], Data[Country] ),
            ORDERBY ( Data[Country Index], ASC )
        )
    )
)

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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.