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
larcaris
Frequent Visitor

How to sum a top5 measure

Hello everybody!!

I need a help with a measure, i need to get a sum of measure SumTOP5, but it can't a column, its necessary to be a measure.

The expected results should be: SumTOP5 = 11.12, and not 1.68, that's been displayed, i dont know where am i missing.

My measures are:

 

*SumTOP5 = IF( and ( [Indexcol] >= 1, [Indexcol] <=5), [TOP5SEPARADO])

*TOP5SEPARADO = var a = IF( AND ( [Indexcol] >=1,[Indexcol] <= 5 ) , [F_Total], 0)
return a

exemplo.png

 Any help id appreciated! thank you!

4 REPLIES 4
v-xuding-msft
Community Support
Community Support

Hi @larcaris ,

There are two ways that you could try.

Sum of sales = SUM('Table'[Sales])

TOP5 = 
SUMX (
    TOPN (
        5,
        FILTER ( 'Table', 'Table'[Index] >= 1 && 'Table'[Index] <= 5 ),
        'Table'[Category], ASC
    ),
    [Sum of sales]
)

TopN =
CALCULATE (
    [Sum of sales],
    TOPN (
        5,
        FILTER ( 'Table', 'Table'[Index] >= 1 && 'Table'[Index] <= 5 ),
        'Table'[Category], ASC
    )
)

4.PNG

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-xuding-msft  My problem is that the "Sales" is a measure too, that do the top5: 

And I am not able to calculate the sum of this measure, to apply your solution  ://

 

top5.png

 

 

 

Hi @larcaris ,

You can use the function of SUMX, like this:

Measure = SUMX(Your_table,[TOP5])

 

If you get any error message, please post here.

 

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

Refer

https://community.powerbi.com/t5/Desktop/Sum-of-TOPN-Columns/td-p/86892

 

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

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.