Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
Hi
i need advice.
I have a spreadsheet of data.
I would need to make two tables:
The first table will show the TOP 2 department by Duration
The second table will be the top1 Code and Code description within the top Department.
Example
Table 1: TOP2 departments (ENG / Maintenance)
Table 2: TOP 1 Code / Code description from ENG and TOP1 code / code description from Maintenance
Or if it was possible to do everything in one table, it would be fantastic.
DATA SOURCE: https://drive.google.com/drive/folders/1cQF3zhHtCLjaFDg7CLSyerMW1qtWbdz6?usp=sharing
Well thank you
@mysho999 , For TOPN Refer
For Rank Refer these links
https://databear.com/power-bi-dax-topn-function/
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
HI @Anonymous
thanks a lot, I'll try today.
just a question ... Will the code work dynamically? What do I think ... Every day, a few hundred rows are added to the database. This means that there can be two different TOP departments every day.
Thank you
Hi @mysho999 ,
For the first table, it's dynamic.
For the second table, I hard-code it to calculate the top 1 for ENG and Maintenance department as you said.
If you want to change it, you need to change the label in the DAX.
Aiolos Zhao
Hi @Anonymous
Hi @mysho999 ,
I create 2 tables using DAX, hope that's what you want:
Table = TOPN(2,SUMMARIZE('Hárok1','Hárok1'[Deparment],"total duration",SUM('Hárok1'[Duration (min)])),[total duration],DESC)
Table 2 = UNION(TOPN(1,SUMMARIZE(FILTER('Hárok1','Hárok1'[Deparment] in {"ENG"}),'Hárok1'[Deparment],'Hárok1'[Code],'Hárok1'[Code description],"top code duration",SUM('Hárok1'[Duration (min)])),[top code duration],DESC),
TOPN(1,SUMMARIZE(FILTER('Hárok1','Hárok1'[Deparment] in {"Maintenance"}),'Hárok1'[Deparment],'Hárok1'[Code],'Hárok1'[Code description],"top code duration",SUM('Hárok1'[Duration (min)])),[top code duration],DESC))
Please try.
Aiolos Zhao
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 61 | |
| 48 | |
| 35 | |
| 25 | |
| 23 |
| User | Count |
|---|---|
| 132 | |
| 105 | |
| 59 | |
| 39 | |
| 31 |