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
ankbaner
Regular Visitor

TOPN DAX function Issue

 

Dear Power BI community ,

 

I am trying to solve a problem related to TOPN DAX function. I want to show list of top 3 products based on their net sales. When I represents products and respective net sales values in a table, and filter the table based on TOPN products, then the total value is showing the correct value.

 

But when I create a dax measure using TOPN function I am getting different  Total result. Though, I am not using any other filters in the report.   A screen shot of the example and below DAX measure I am using is provided in the below table format. 

 

How I can correct TOTAL NET SALES VALUES of TOP 3 products by using DAX measure ?

 

= SUMX(

        TOPN(

            3,

            SUMMARIZE(

                    Sales,

                    Sales[ProductKey],

                    "NetSales", SUM(InternetSales[SalesAmount])

            ),

            [NetSales], DESC

        ),

        [NetSales]

)

 

 

ankbaner_1-1744040230521.png

 

 

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @ankbaner  -You're absolutely right to observe the discrepancy

TopN Net Sales =
VAR TopProducts =
TOPN(
3,
ADDCOLUMNS(
VALUES(Sales[ProductKey]),
"NetSales", CALCULATE(SUM(InternetSales[SalesAmount]))
),
[NetSales], DESC
)
RETURN
SUMX(
TopProducts,
[NetSales]
)

Hope this works.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

6 REPLIES 6
v-sdhruv
Community Support
Community Support

Hi @ankbaner ,
Just wanted to check if you had the opportunity to review the information provide?
.
If his response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-sdhruv
Community Support
Community Support

Just wanted to check if you had the opportunity to review the information provide?.
If his response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-sdhruv
Community Support
Community Support

Hi @ankbaner ,
Just wanted to check if you had the opportunity to review the information provided by @rajendraongole1  .
If his response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-sdhruv
Community Support
Community Support

Hi @ankbaner ,
Just wanted to check if you had the opportunity to review the information provided by @rajendraongole1  .
If his response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

rajendraongole1
Super User
Super User

Hi @ankbaner  -You're absolutely right to observe the discrepancy

TopN Net Sales =
VAR TopProducts =
TOPN(
3,
ADDCOLUMNS(
VALUES(Sales[ProductKey]),
"NetSales", CALCULATE(SUM(InternetSales[SalesAmount]))
),
[NetSales], DESC
)
RETURN
SUMX(
TopProducts,
[NetSales]
)

Hope this works.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi,

 

Thank you for contributing to create solution. The given formula did not help to get the actual result. The outcome of the formula still shows difference compared to Top n Filter

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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