Forum Discussion
alialsayer
Helper I
5 years agoTopN
Dears, I just need help as I am trying to find out the following Top X customer name by sales & at each state Total Top X by country each state should have Top X customers (for example Ohio ...
- 5 years ago
Hi alialsayer ,
Hi
Pls try the following measure:
1.Top X customer name by sales & at each state
Top test = VAR TopV = SELECTEDVALUE ( 'Parameter Top X'[Top X] ) VAR test2 = RANKX ( ALL ( 'Product' ), CALCULATE ( SUM ( 'Product'[Sales $] ) ), , DESC, DENSE ) VAR test3 = IF ( test2 > SELECTEDVALUE ( 'Parameter Top X'[Top X] ), BLANK (), test2 ) RETURN test32.Total Top X by country each state should have Top X customers (for example Ohio top 10 customers sales are 400$ , California have 10 customers sales are 300$ the total wil be 700 $)
Top sumsales = VAR TopV = SELECTEDVALUE ( 'Parameter Top X'[Top X] ) VAR test4 = CALCULATE ( SUM ( 'Product'[Sales $] ), FILTER ( ALL ( 'Product' ), RANKX ( ALL ( 'Product' ), CALCULATE ( SUM ( 'Product'[Sales $] )), , DESC, DENSE ) <= SELECTEDVALUE ( 'Parameter Top X'[Top X] )&&'Product'[state]=MAX('Product'[state])) ) RETURN test43.Top X percentage for each state which is Top X / total sales
Top sumsalespercnt = VAR TopV = SELECTEDVALUE ( 'Parameter Top X'[Top X] ) VAR test1 = CALCULATE ( SUM ( 'Product'[Sales $] ), FILTER ( ALL ( 'Product' ), RANKX ( ALL ( 'Product' ), CALCULATE ( SUM ( 'Product'[Sales $] ) ), , DESC, DENSE ) <= SELECTEDVALUE ( 'Parameter Top X'[Top X] ) && 'Product'[state] = MAX ( 'Product'[state] ) ) ) VAR test2 = CALCULATE ( SUM ( 'Product'[Sales $] ), FILTER ( ALL ( 'Product' ), 'Product'[state] = MAX ( 'Product'[state] ) ) ) VAR TEST3 = DIVIDE ( test1, test2, 4 ) RETURN TEST3You could download my pbix file if you need!
WIsh it is helpful for you!
Best Regards
Lucien
alialsayer
Helper I
5 years agoThanks, v-luwang-msft for your professionality, yes this is what I am looking for i appreciate your help thanks again