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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.