Skip to content

Instantly share code, notes, and snippets.

@malinxiao
Created December 11, 2017 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malinxiao/5ed85e54f78b267c9543888d8ffe7038 to your computer and use it in GitHub Desktop.
Save malinxiao/5ed85e54f78b267c9543888d8ffe7038 to your computer and use it in GitHub Desktop.
Rank by OrderQty =
VAR IsProductFiltered = ISFILTERED('Product'[Product Name])
VAR IsProductCategoryFiltered = ISFILTERED(ProductCategory[Product Category])
RETURN
IF (IsProductFiltered && IsProductCategoryFiltered,
RANKX(ALL('Product'[Product Name]), CALCULATE(SUM(SalesOrderDetail[OrderQty]))),
IF (NOT IsProductFiltered && IsProductCategoryFiltered,
RANKX(ALL(ProductCategory[Product Category]), CALCULATE(SUM(SalesOrderDetail[OrderQty]))),
BLANK()
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment