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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Cookistador
Helper II
Helper II

Top n With matrix and date

Hi everyone,

 

I'm facing an issue with Power BI & Matrice, I have some projects with task associated, I created a matrix in which I would like for each project to return the 2 with the earliest start date

So this a dataset sample

Project NameTaskStart Date
ProjectAPython script01/01/2023
ProjectAJava script16/01/2023
ProjectAC# Script02/02/2023
ProjectBC++ Script05/03/2023
ProjectBC Script29/03/2023
ProjectBRuby Script17/04/2023
ProjectCPowershell Script02/03/2023
ProjectCRust Script11/04/2023
ProjectCJS Script17/05/2023
ProjectCNode Script01/06/2023

 

And I would like to get something like:

ProjectA  
 Python script01/01/2023
 Java script16/01/2023
ProjectB  
 C++ Script05/03/2023
 C Script29/03/2023
ProjectC  
 Node Script01/02/2023
 Powershell Script

02/03/2023

 

Any idea of how could I achieve that?

I tried Top N but it returns me something weird 

 

Many thanks in advance for your help

1 ACCEPTED SOLUTION

rnk = 
var a = CALCULATETABLE(SUMMARIZE('Table',[Task],"md",min([Start Date])),REMOVEFILTERS('Table'[Task]))
return rank(SKIP,a,ORDERBY([md],ASC))

 

You cannot rank duplicate items. The SUMMARIZE part removes that ambiguity

 

lbendlin_0-1696372230873.png

 

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

lbendlin_0-1696087942912.png

rnk = RANK(SKIP,Allselected('Table'),ORDERBY('Table'[Start Date]),LAST,PARTITIONBY('Table'[Project Name]))

Note this is done as a measure , just in case. If you don't expect user interaction you can change it to a calculated column.

Thank you for your help

I still have a last blocking point 😕
If two tasks have the same name in a project, it doesn't work
For my ProjectC, I added the following value 

ProjectCPowershell Script02/03/2023
ProjectCRust Script09/04/2023
ProjectCRust Script11/04/2023
ProjectCJS Script17/05/2023
ProjectCNode Script01/02/2023

 

So as you see, there are two tasks called Rust script, but the measure doesn't return any rank for this value

Cookistador_0-1696362807761.png

 

I tried a few things like creating a kind of sugorate key or adding another parameter in the order by but it doesn't work

 

Any clue of waht I can do?

 

rnk = 
var a = CALCULATETABLE(SUMMARIZE('Table',[Task],"md",min([Start Date])),REMOVEFILTERS('Table'[Task]))
return rank(SKIP,a,ORDERBY([md],ASC))

 

You cannot rank duplicate items. The SUMMARIZE part removes that ambiguity

 

lbendlin_0-1696372230873.png

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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