Question :
What is the difference between implication of using measure -Sales Amt vs Sales Amt-withoutValues in sheet name FIG03-final result
(ps literal difference is one has values but other don’t have values that’s it )
C0120 - Filter top 3 products with a row for others using DAX in Power BI.pbix (2.0 MB)
Sales Amt =
VAR SalesOfAll =
CALCULATE (
[Sales Amount],
REMOVEFILTERS ( 'Product Names' )
)
RETURN
IF (
NOT ISINSCOPE ( 'Product Names'[Product Name] ),
-- Calculation for a group of products
SalesOfAll,
-- Calculation for one product name
VAR ProductsToRank = [TopN Value]
VAR SalesOfCurrentProduct = [Sales Amount]
VAR IsOtherSelected =
SELECTEDVALUE ( 'Product Names'[Product Name] ) = "Others"
RETURN
IF (
NOT IsOtherSelected,
-- Calculation for a regular product
SalesOfCurrentProduct,
-- Calculation for Others
VAR VisibleProducts =
CALCULATETABLE (
-- *****QUESTION-One measure has values other don't ***********
VALUES ( 'Product' ),
ALLSELECTED ( 'Product Names'[Product Name] )
)
VAR ProductsWithSales =
ADDCOLUMNS (
VisibleProducts,
"@SalesAmount", [Sales Amount]
)
VAR SalesOfTopProducts =
SUMX (
TOPN (
ProductsToRank,
ProductsWithSales,
[@SalesAmount]
),
[@SalesAmount]
)
VAR SalesOthers =
SalesOfAll - SalesOfTopProducts
RETURN
SalesOthers
)
)
Notes :
Sir Marco Russo replied to same question that I asked under comments but I could not understand with the explanation
Context :
I am not looking for alternative solution of this problem, I am more interested in understanding the nuance of the measure created by Dax maestro ,considering the fact that they don’t write single line without any thought process /rationale behind
Answer criteria
I am looking for theory along with example based answer on what is the difference between the two measure , One reason Marco pointed out in comments is performance; or there may be others . .
I am looking for answer in one or more of following or more track
a) Is there any functional use case that make Marco Russo put the Values function over there -Pls explain with eg.
b) If its for performance reason ,Please illustrate with sample example with explanation pls
c)If none of a) and b) is true , that means that values function as present in measure “Sales Amt” is redundant as per use case present by Marco Russo , Please mention as option c ,its redundant
Sheet FIG03-final result
Reference