The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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]
)
Solved! Go to Solution.
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.
Proud to be a Super User! | |
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.
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.
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.
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.
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.
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