Hi All, I have used the Top N function to derive Top 10 SKU Sales , but when I compare it with the excel version pivot table , the results show different numbers for some. There is a filter slicer that filters the year for 2020.
I have used the following DAX function:
Top 10 SKU Sales = CALCULATE([Total Sales],
TOPN(10,ALL(Products),[Total Sales],DESC),VALUES(Products[SKU]))
Well, there was minor fix into the formula and the results will be achieved as you’re expecting. You’d reference the formula as “ALL( Products )” i.e. referencing the naked table whilst it should have been “ALL( Products[SKU] )” referencing a particular column. Below are the formulas alongwith the screenshot of the result provided for the reference -
Super!..Got it, its a subtle change that can make a difference.
ALL accepts a table or a column, how would one know when to use which one as it can be quite easily confusing.
@chris786 The thing to remember is deciding the right granularity your DAX calculation is to be done on. Context Transition is adding Barcode, SKU and Cost into an equivalent filter context, since you are iterating full table, there are going to be multiple rows for each SKU.
When you write ALL ( Products ) and sort by Sales, only one row of EAJB 3060 is visible in the Top 10.
Hi @chris786, did the response provided by the experts help you solve your query? If not, how far did you get and what kind of help you need further? If yes, kindly mark the thread as solved. Thanks!