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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

TOPN with start end date subcategory table

Hi,

 

It's a complex problem (I think) and I'm not even sure how to explain it. But lets try.

I have three tables:

1 - Agents (agents the work on the call center in chat or phone. They can switch between positions over time)

ID_AgentName_Agent
1John
2Peter
3Mark
4Marie

 


2 - Agent_Funcion

ID_AgentFunctionStartDateEndDate
1PHONE01/10/2022 
2PHONE01/10/202231/10/2022
2CHAT01/11/2022 
3CHAT01/10/202231/10/2022
3PHONE01/11/2022 
4PHONE01/10/202231/10/2022
4CHAT01/11/2022 

 

 

3 - Agent_Login

DateID_AgentTimeLogin_Seconds
30/10/2022110.800
31/10/2022110.700
01/11/202218.000
02/11/2022110.000
30/10/2022210.500
31/10/2022210.300
01/11/2022211.000
02/11/2022 29.300
30/10/2022310.200
31/10/2022310.200
01/11/2022310.000
02/11/2022 310.300
30/10/2022410.800
31/10/2022410.500
01/11/202248.400
02/11/2022 410.100


So here I have that the average of work for each agent is

(This table is just to facilitate the explanation. It is not necessary to be built)

ID_Agent MonthAverage_Seconds
1october10.750
1november9.000
2october10.400
2november10.150
3october10.200
3november10.150
4october10.650
4november9.250

 

I have two filters Date and Function and at the end I need to show the TOP1 that has the worst working time average of the function and month selected (in my real data I will show the TOP10). Here are the outcomes expected, based on the example.

 

If the Filters are OCTOBER + PHONE
Name_Agent Worst_Average_Seconds
Peter 10.400


If the Filters are OCTOBER + CHAT
Name_Agent Worst_Average_Seconds
Mark 10.200


If the Filters are NOVEMBER + PHONE
Name_Agent Worst_Average_Seconds
John 9.000


If the Filters are NOVEMBER + CHAT
Name_Agent Worst_Average_Seconds
Marie 9.250

 

Thanks in advance for the help.

 

Best Regards.

2 REPLIES 2
v-jialluo-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please follow these steps:

(1) Create new measures

Avg = AVERAGE(Agent_Login[TimeLogin_Seconds])

 

MIN =
MINX(SUMMARIZE( FILTER( 'Agent_Funcion',[StartDate]<=MAX('Agent_Login'[Date])&&([EndDate]>=MAX('Agent_Login'[Date])||[EndDate]=BLANK())),[ID_Agent],"1",[Avg]),[1])

 

(2)Final output

vjialluomsft_0-1669718660524.png

 

vjialluomsft_1-1669718660525.png

 

 

Best Regards,

Gallen Luo

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @v-jialluo-msft 

Thanks a lot for the answer...

Its almost there. I've forgotten to say that I'm using a calendar table and for this reason I'm struggling with the [EndDate] because I need to use the USERELATIONSHIP or TREATAS to make this relation active, since I have already an active relation with the [StartDate]. Another thing I think is gonna be a problem after this is the TOPN, because I need to make sure that 10 values are going to appear on the table (1 in this example). The MINX will show only the TOP 1, but my real problem is with TOP 10.

I'll keep trying here, and will come back with the answer if I get it.

 

Thanks a lot again.

Raoni

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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