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 display a SUM of n first rows of a table in a card

Hello !

 

I have a table with :

column 1 : product ID

colums 2 : the sales for each product

column 3 : the rank of each product (based on the column 2, so "1" is the most sold). This column is created with RANKX, it is a measure)

column 4 : an other measure (number)

 

I would like to calculate in a card the sum of the 150 first rows (value of column 3 between 1 and 150) of the column 4.

 

Is that possible ? How wounld you do that ?

 

Thanks for your help !

 

6 REPLIES 6
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could try it .(here is a simple file that i calculate top 10.)

Measure = SUMX(FILTER(ALL('Table'),[RANK]<=10),[4col])

The final output is shown below:

vyalanwumsft_0-1641273830902.png

 


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this measure:

Measure = 
VAR _A =
    ADDCOLUMNS (
        FILTER ( ALL ( 'Table' ), 'Table'[Column3] <= 4 ),
        "C4", [column 4]
    )
RETURN
    SUMX ( _A, [C4] )

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

smpa01
Super User
Super User

@Anonymous  provide a sample pbix

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

Hi @amitchandak thank but it does not work 🙂

 

Actually my column 4 is a measure which is already created using a SUM function.

 

But thanks for your help anyway.

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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
amitchandak
Super User
Super User

@Anonymous , If column three is column not measure

then

calculate(sum(Table[Column 4]), filter(Table, Table[Column3] >=1 && Table[Column3] <=150 ) ) 

 

you can avoid sum if column 4 is a measure

 

a measure if you need

calculate(sum(Table[Column4]),TOPN(150,allselected(table[Column1]),calculate(sum(Table[Column4])) DESC), values(table[Column1]))

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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