Hi,
Would like to seek for your help what is the problem of my DAX.
Top N Customers by Sales Value CM =
VAR myNNum = SELECTEDVALUE ( NNumber20[NNumber] )
Var myTopBottom = SELECTEDVALUE ( DimTopBottom[TopBottom] )
VAR myPeriod =
SELECTEDVALUE ( DimDatesAttributes[NAttribute] )
VAR myTopSalesMth =
CALCULATE (
[Sales CM],
FILTER (
VALUES ( DimAR_CUSTOMER[COMPANYNAME] ),
IF (
ISBLANK ( [Sales CM] ),
BLANK (),
RANKX (
FILTER ( ALL ( DimAR_CUSTOMER[COMPANYNAME] ), NOT ( ISBLANK ( [Sales CM] ) ) ),
[Sales CM],
,
DESC
) <= myNNum
)
)
)
VAR myBottomSalesMth =
CALCULATE (
[Sales CM],
FILTER (
VALUES ( DimAR_CUSTOMER[COMPANYNAME] ),
IF (
ISBLANK ( [Sales CM] ),
BLANK (),
RANKX (
FILTER ( ALL ( DimAR_CUSTOMER[COMPANYNAME] ), NOT ( ISBLANK ( [Sales CM] ) ) ),
[Sales CM],
,
ASC
) <= myNNum
)
)
)
RETURN
SWITCH ( myTopBottom, "Top", myTopSalesMth, "Bottom", myBottomSalesMth )
However, when i include Agent Name, it become as follows:
Any idea what’s wrong with my DAX to generate the Agent Sales by Top N Customers?
Your advise was highly appreciated.
Thank you.
Dennis Tiong