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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.