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
omillzy
Helper III
Helper III

Top N per group

Case_Category__cDepartment# Cases
Ad hoc invoice/ credit note requestsBilling51
Contract queriesBilling4
Development invoice/ credit note requestsBilling2
Invoice/ credit note release requestsBilling5
Invoice/Credit note QueriesBilling46
OtherBilling19
Refund requestsBilling3
Allocation queriesCash - General14
Bank detail info requestCash - General1
OtherCash - General22
RemittancesCash - General5
Specific transaction enquiryCash - General5
Ad hoc requestsCash - Notifications33
Change of bank detailsCash - Notifications10
Expenses formsCash - Notifications64
Expenses queriesCash - Notifications10
OtherCash - Notifications4
RemittancesCash - Notifications5
Soldo top up requestsCash - Notifications8


I want to show the top 3 case category's, by department. I've tried all sorts of ranking measures but none seem to work. The # cases column is a measure, counting the case ID in my case table

 

Any help would be appreciated

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Capture.PNGNow It's working as per your expectation.

Rank2 = var a = RANKX(ALLSELECTED('Case'[Case_Category__c]),[# Cases],[# Cases],DESC,Dense) var b = SWITCH(SELECTEDVALUE(Dummy[Input]),"1",1,"2",2,"3",3,"4",4,"All",99) return if(a<=b,1,0)

 

 

Make sure here we are checking for first 4 and 'all' as 5th input.  Just modify var b as per your requirement

 

Thanks & Regards,

Pravin

View solution in original post

17 REPLIES 17
V-pazhen-msft
Community Support
Community Support

@omillzy 

1. I ranked the measure #Case by department using the following DAX: 

 

Rank Measure = RANKX( ALLEXCEPT('Table', 'Table'[Department]), [#Case measure],, DESC)

 

2. The next step is to set a visual level filter to the Rank measure: 

rank measure.JPG

Paul,
Best

@V-pazhen-msft thanks for your response,

This is what I have tried - but strangely it doesn't rank as expected, see below.

 

Capture.PNG

Anonymous
Not applicable

Ceate one dummy table with input column.

Input

1

2

.

..

..

20

 

Use this column for accepting N input.

Then create below measure.

 

Rank =
var a =RANKX(ALLSELECTED('table'Department),[#cases],,DESC,Dense)
var b =SWITCH(SELECTEDVALUE('Dummy'[Input]),"1",1,"2",2,"3",3,"4",4,"5",5,"All",99)
return
if(a<=b,1,0)

 

Anonymous
Not applicable

Then add measure in visual level filter and set rank is not 0.

 

If i solve your problem, Mark it as solution.

 

Thanks,

Pravin

@Anonymous This doesn't seem to work. I have created a dummy table (called Dummy), with one column (called Input) going from numbers 1-20 and created the Rank measure as you've shown, when I put this as a visual filter, or into the table I get the following error:

Capture.PNG

@Anonymous Ok i had to convert the Dummy[Input] column to type text, I've done that and it's just giving me a rank of 0 for everythingCapture.PNG

Anonymous
Not applicable

have you selected anything is input slicer?

If not then select any value in Slicer else update selectedvalue function.

Anonymous
Not applicable

in*

 

Same measure is working in my case . We have same client requirement.

Anonymous
Not applicable

Sorry I forgot to mention. ADd measure in visual level filter as well and set measure is not zero.

They u can test for top N values by selecting different values in input dropdown

@Anonymous No it just doesn't work, there should only be 3 entries per reasonCapture.PNG

 

Here's my code for the measure in case I am doing something wrong?Capture.PNG

Anonymous
Not applicable

Could you share your dataset? (www.linkedin.com/in/pravin-p-wattamwar)

 

Please check on your relationship(one to many or many to one)

Anonymous
Not applicable

Update measure
 
Rank =
var a =RANKX(ALLEXCEPT(Data,Data[Department]),[#Cases],[#Cases],DESC,Dense)
var b =SWITCH(SELECTEDVALUE(Input[Input]),"1",1,"2",2,"3",3,"4",4,"All",99)
return
if(a<=b,1,0)
 
 

Capture1.PNG

Anonymous
Not applicable

Capture.PNGNow It's working as per your expectation.

Rank2 = var a = RANKX(ALLSELECTED('Case'[Case_Category__c]),[# Cases],[# Cases],DESC,Dense) var b = SWITCH(SELECTEDVALUE(Dummy[Input]),"1",1,"2",2,"3",3,"4",4,"All",99) return if(a<=b,1,0)

 

 

Make sure here we are checking for first 4 and 'all' as 5th input.  Just modify var b as per your requirement

 

Thanks & Regards,

Pravin

@Anonymous Yes I have added the Input slicer and selected 1, 2 & 3.

Perhaps it works for you but not me because the actual data is different, in the original post, I gave the summarised table, my raw data looks like this:

So each row has a whole load of data associated with a case, including the department and a category.

 

Dept.Case_Category__c
BillingAd hoc invoice/ credit note requests
BillingOther
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingOther
BillingOther
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingOther
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingOther
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingContract queries
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingOther
BillingInvoice/Credit note Queries
BillingOther
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingOther
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingOther
BillingOther
BillingOther
BillingAd hoc invoice/ credit note requests
BillingOther
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingRefund requests
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingOther
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingOther
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingRefund requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingRefund requests
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingOther
BillingOther
BillingAd hoc invoice/ credit note requests
BillingContract queries
BillingAd hoc invoice/ credit note requests
BillingDevelopment invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingOther
BillingAd hoc invoice/ credit note requests
BillingInvoice/ credit note release requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingDevelopment invoice/ credit note requests
BillingContract queries
BillingInvoice/Credit note Queries
BillingOther
BillingInvoice/Credit note Queries
BillingInvoice/ credit note release requests
BillingInvoice/ credit note release requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingContract queries
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingInvoice/Credit note Queries
BillingAd hoc invoice/ credit note requests
BillingInvoice/ credit note release requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingAd hoc invoice/ credit note requests
BillingOther
BillingInvoice/ credit note release requests
Cash - GeneralOther
Cash - GeneralAllocation queries
Cash - GeneralAllocation queries
Cash - GeneralOther
Cash - GeneralOther
Cash - GeneralOther
Cash - GeneralOther
Cash - GeneralOther
Cash - GeneralAllocation queries
Cash - GeneralAllocation queries
Cash - GeneralOther
Cash - GeneralAllocation queries
Cash - GeneralOther
Cash - GeneralOther
Cash - GeneralOther
Cash - GeneralRemittances
Cash - GeneralRemittances
Cash - GeneralRemittances
Cash - GeneralOther
Cash - GeneralAllocation queries
Cash - GeneralAllocation queries
Cash - GeneralAllocation queries
Cash - GeneralOther
Cash - GeneralOther
Cash - GeneralAllocation queries
Cash - GeneralOther
Cash - GeneralSpecific transaction enquiry
Cash - GeneralSpecific transaction enquiry
Cash - GeneralOther
Cash - GeneralSpecific transaction enquiry
Cash - GeneralAllocation queries
Cash - GeneralOther
Cash - GeneralRemittances
Cash - GeneralAllocation queries
Cash - GeneralOther
Cash - GeneralOther
Cash - GeneralOther
Cash - GeneralSpecific transaction enquiry
Cash - GeneralAllocation queries
Cash - GeneralOther
Cash - GeneralOther
Cash - GeneralBank detail info request
Cash - GeneralAllocation queries
Cash - GeneralOther
Cash - GeneralSpecific transaction enquiry
Cash - GeneralRemittances
Cash - GeneralAllocation queries
Anonymous
Not applicable

it should be single select not multi select.

Select only one value in input slicer.

Hmm @Anonymous , ok I have selected just '1' on the input slicer - and now the Rank is pulling values through, but it's not showing the top 3. Strangely, it doesn't even pick up the top number: 116Capture.PNG

omillzy
Helper III
Helper III

So for example, for 'Billing' department, I want a measure (or visual filter) that can be used on a bar chart so I only see 'Ad hoc invoice/ credit note requests', 'Invoice/Credit note Queries' and 'Other' - the top 3 (by # cases)

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.