Forum Discussion
Suzy123
4 years agoNew Member
Top N and Others
Hi all, I am doing a top 5 plus others for my report, and it works fine until i put the month in the columns it will show top 5 for each month and Total column will only add the Top 5 based on t...
- 4 years ago
Hi,
I tried to simplify the sample and created a new sample pbix file like below. (top3 and others)
Please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your data model.
Top 3 sales and others: = VAR _topthreecustomerlistwholeyear = TOPN ( 3, ALLSELECTED ( Customer[Customer] ), CALCULATE ( [Sales total:], REMOVEFILTERS ( 'Calendar' ) ), DESC ) VAR _topthreefilter = TOPN ( 3, ALLSELECTED ( Customer[Customer] ), [Sales total:], DESC ) VAR _allsales = CALCULATE ( [Sales total:], REMOVEFILTERS ( Customer ) ) VAR _othersales = _allsales - CALCULATE ( [Sales total:], _topthreefilter ) RETURN SWITCH ( TRUE (), HASONEVALUE ( Customer[Customer] ), IF ( SELECTEDVALUE ( Customer[Customer] ) = "Others", _othersales, CALCULATE ( [Sales total:], KEEPFILTERS ( Customer[Customer] IN _topthreecustomerlistwholeyear ) ) ), [Sales total:] )
Jihwan_Kim
Super User
4 years agoHi,
I tried to simplify the sample and created a new sample pbix file like below. (top3 and others)
Please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your data model.
Top 3 sales and others: =
VAR _topthreecustomerlistwholeyear =
TOPN (
3,
ALLSELECTED ( Customer[Customer] ),
CALCULATE ( [Sales total:], REMOVEFILTERS ( 'Calendar' ) ), DESC
)
VAR _topthreefilter =
TOPN ( 3, ALLSELECTED ( Customer[Customer] ), [Sales total:], DESC )
VAR _allsales =
CALCULATE ( [Sales total:], REMOVEFILTERS ( Customer ) )
VAR _othersales =
_allsales - CALCULATE ( [Sales total:], _topthreefilter )
RETURN
SWITCH (
TRUE (),
HASONEVALUE ( Customer[Customer] ),
IF (
SELECTEDVALUE ( Customer[Customer] ) = "Others",
_othersales,
CALCULATE (
[Sales total:],
KEEPFILTERS ( Customer[Customer] IN _topthreecustomerlistwholeyear )
)
),
[Sales total:]
)
- Suzy1234 years agoNew Member
Appreciate your help!! Genius! It works now 🙂