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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ExcelMonke
Continued Contributor
Continued Contributor

Summarize Tables with TopN / RankX Help

Hello, I am trying to get a summarized table that filters the TopN / Rank for a given aggregation. For some detail, I have the following table of data:
Table 1: "Encounters"

Dept ID  EncounterID  Date
111

32453245

1/1/2023
22232462623

2/4/2023

333656543333/7/2023
1112658776511/2/2022
111 11/4/2022
2223687476912/1/2023
333 8/3/2023
111736584981/21/2023
444476943627/9/2023

 

This table "Inter" has a relationship with the following table, one to many relationship to 'Encounter' based on DeptID

DeptID  DeptID2  DeptName  
111ABCJim's Facility
222DEFBob's Facility
333GHIJane's Facility
444JKLMary's Facility

 

This table in turn is has a relationship one to many with table 3 "DeptListing" as following

DeptID2  DeptName  
ABCJim's Facility
DEFBob's Facility
GHIJane's Facility
JKLMary's Facility

 

My intended result is this:

DeptNameEncounter Count
Jim's Facility3
Bob's Facility2
Jane's Facility1
Mary's Facility1

 

I have currently tried this to no avail:

 

Summarized Table by Top N = 
VAR _N = 4
VAR _SUMMARIZED =
    SUMMARIZE (Inter, 
    DeptListing[DeptName],
    "Encounter Count", COUNT(Encounters[EncounterID]))
VAR _ADDRANK =
    ADDCOLUMNS ( _SUMMARIZED, "RANK", RANKX ( _SUMMARIZED, [DeptName],, DESC ) )
VAR _TopN =
    SUMMARIZE ( FILTER ( _ADDRANK, [RANK] <= _N ),  [DeptName])
RETURN
    _TopN

 

 

Any help is appreciated!

1 ACCEPTED SOLUTION
v-xiandat-msft
Community Support
Community Support

Hi @ExcelMonke ,

Below is my table1:

vxiandatmsft_0-1703136482347.png

Below is my table2 :

vxiandatmsft_1-1703136502539.png

Below is my table3:

vxiandatmsft_2-1703136522830.png

The following DAX might work for you:

 

Measure = CALCULATE(
    COUNTROWS(Encounters),
    FILTER(Encounters,Encounters[Encounter ID]<>BLANK()),
    ALL(Encounters)
)

 

The final output is shown in the following figure:

vxiandatmsft_3-1703136602880.png

 

 

Best Regards,

Xianda Tang

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

1 REPLY 1
v-xiandat-msft
Community Support
Community Support

Hi @ExcelMonke ,

Below is my table1:

vxiandatmsft_0-1703136482347.png

Below is my table2 :

vxiandatmsft_1-1703136502539.png

Below is my table3:

vxiandatmsft_2-1703136522830.png

The following DAX might work for you:

 

Measure = CALCULATE(
    COUNTROWS(Encounters),
    FILTER(Encounters,Encounters[Encounter ID]<>BLANK()),
    ALL(Encounters)
)

 

The final output is shown in the following figure:

vxiandatmsft_3-1703136602880.png

 

 

Best Regards,

Xianda Tang

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

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

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.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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