Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rajeev16
New Member

top N customer based on filter

Hi All,

I have a transactional data of all customer sales for a year. I need to filter only the records of the top N ( 10/20/30 based onfilter ) customers based on the month or quater filter i would be having.

Thank you

1 ACCEPTED SOLUTION
v-haibl-msft
Employee
Employee

@rajeev16

 

If you have a table like below, you can first create a Calendar table and create relationship between transactional table and Calendar table with Date key.

top N customer based on filter_1.jpg

 

Calendar = 
CALENDAR ( "1/1/2016", "12/31/2016" )

Then create two Columns in the Calendar table for the Month and Quarter slicer.

Month = 
MONTH ( 'Calendar'[Date] )
Quarter = 
ROUNDUP ( MONTH ( [Date] ) / 3, 0 )

Create a measure to rank the customer according to selection in the Month and Quarter slicer.

Rank = 
RANKX ( ALL ( Table1[Customer] ), CALCULATE ( SUM ( Table1[Sales] ) ) )

top N customer based on filter_2.jpg

 

I’ve also uploaded my .pbix file here for reference.

 

Best Regards,

Herbert

View solution in original post

3 REPLIES 3
v-haibl-msft
Employee
Employee

@rajeev16

 

If you have a table like below, you can first create a Calendar table and create relationship between transactional table and Calendar table with Date key.

top N customer based on filter_1.jpg

 

Calendar = 
CALENDAR ( "1/1/2016", "12/31/2016" )

Then create two Columns in the Calendar table for the Month and Quarter slicer.

Month = 
MONTH ( 'Calendar'[Date] )
Quarter = 
ROUNDUP ( MONTH ( [Date] ) / 3, 0 )

Create a measure to rank the customer according to selection in the Month and Quarter slicer.

Rank = 
RANKX ( ALL ( Table1[Customer] ), CALCULATE ( SUM ( Table1[Sales] ) ) )

top N customer based on filter_2.jpg

 

I’ve also uploaded my .pbix file here for reference.

 

Best Regards,

Herbert

ankitpatira
Community Champion
Community Champion

@rajeev16 Easy way to do is to sort the visual ie if you're using column or bar chart click on three dots on top right hand corner and sort by field that you've used for Values section that will give you the top to bottom view and limit the size of the visual so that you're only seeing top 10 rows.

 

Complex way is to use RANKX function to get ranking of the values and then use visual-level filter to limit that to only show upto 10.

thanks ankit.

 

I am looking for the Rank command to filter the records of the top 10 customers. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.