Forum Discussion

ankbaner's avatar
ankbaner
Regular Visitor
1 year ago
Solved

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...
  • rajendraongole1's avatar
    1 year ago

    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.