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
ImaginaCorregir
Regular Visitor

Calculate the id with the maximum number of repetitions in the last month

Hi all!

As I've specified on the title, I'm trying to get the id (In my case, a username) with the maximun number of repetitions on a table, in the last month. More specifically, I need to search what user make the most number of commits on last month, and display the username on a view.

 

I have this two tables:

ImaginaCorregir_0-1600243921052.png

 

Someone can tell me what can i do?

Thanks in advance!

1 ACCEPTED SOLUTION

@ImaginaCorregir 

Try this measure and you may my sample in the pbix below:

 

Measure = CALCULATE(MAX('Usuarios'[Nombre]),FILTER('Datos commits', [Usuario] = CALCULATE(COUNT([Usuario]),FILTER(ALL('Datos commits'),[Usuario]=MAX('Datos commits'[Usuario])))))

 

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
  

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@ImaginaCorregir ,

Measure like

commits = count(Table[ID commit])

 

Create Rank and filter or have top N
rank = rankx(all(Table[userio]),[commits])

Top 5 = CALCULATE([commits],TOPN(5,all(Table[userio]),[commits],DESC),VALUES(Table[userio]))

Hi @amitchandak, thanks for the quick reply.

I've just try that but It's not working as I expected. Thats the code:

 

MayorContribuidorMes = 

VAR commits = COUNT('Datos commits'[ID Commit])
VAR rankUsuario = RANKX(ALL(Usuarios[Nombre]), commits)

RETURN CALCULATE(
commits,
TOPN(1, ALL(Usuarios[Nombre]), commits, DESC),
VALUES(Usuarios[Nombre])
)

And on my view I'm seeing the total number of commits:

 

 
 
 
Captura de pantalla 2020-09-16 104332.png

 

Also, I cant see on that Dax function where it's filtering commits table by date (by last month). I have managed to create this code for it:

VAR commitsLastMonth = FILTER(
'Datos commits',
AND(
YEAR([Fecha]) = YEAR(TODAY()),
MONTH([Fecha]) = MONTH(TODAY())
)
)

@ImaginaCorregir 

Try this measure and you may my sample in the pbix below:

 

Measure = CALCULATE(MAX('Usuarios'[Nombre]),FILTER('Datos commits', [Usuario] = CALCULATE(COUNT([Usuario]),FILTER(ALL('Datos commits'),[Usuario]=MAX('Datos commits'[Usuario])))))

 

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
  

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.