Forum Discussion
Irshadn03
4 years agoFrequent Visitor
Top N + Others but total is not adding up
I was trying to do "Top N + others", tried many options from different community and finaly only one solution worked for me from below link, https://www.goodly.co.in/top-n-and-others-power-bi/ Now ...
- 4 years ago
This is because your CurrentProd is blank for the Total case (since multiple Products are in scope).
Try updating the RETURN part of your DAX to this:
RETURN IF( ISBLANK ( CurrentProd ), TopProdSales + OtherSales, IF ( CurrentProd <> "Others", TopProdSales, OtherSales ) ) - 4 years ago
Hmm. Maybe the bottom products don't have any sales, so they're returning blank.
Irshadn03
4 years agoFrequent Visitor
Tried it but getting only "Others" total.
Top N Sum Sales v2 =
VAR TopNSelected = SELECTEDVALUE('TopN Selection'[Value])
VAR TopProdTable =
TOPN(
TopNSelected,
ALLSELECTED('Pseudo Prod Table'),
[Total Sales],ASC
)
VAR TopProdSales =
CALCULATE(
[Total Sales],
KEEPFILTERS( TopProdTable )
)
VAR OtherSales =
CALCULATE(
[Total Sales],
ALLSELECTED('Pseudo Prod Table')
) -
CALCULATE(
[Total Sales],
TopProdTable
)
VAR CurrentProd = SELECTEDVALUE('Pseudo Prod Table'[Product])
RETURN
IF(
ISBLANK ( CurrentProd ),
TopProdSales + OtherSales,
IF (
CurrentProd <> "Others",
TopProdSales,
OtherSales
)
)here is the output
AlexisOlson
Super User
4 years agoHmm. Maybe the bottom products don't have any sales, so they're returning blank.