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
rbreneman
Helper II
Helper II

In need of a measure outputting text value based on frequency of another text value

Hi!

 

I want to write a measure that will produce the person with the top number of closed tickets for today, excluding any tickets that have a blank owner. I've included an example below of my data structure. Using this example and assuming today's date is 6/1/2021 the measure would output "Frank (2)". I suppose it's possible there could be a tie score at some point in the day, so if we can account for that with something like "TIE - Frank and George (15)" that would be awesome.

 

I know I need a filter for DateClosed >= TODAY() && Owner <> BLANK() but I'm struggling with how to use DISTINCTCOUNT and other functions to get to my end goal. I've been trying various combinations of TOPN and RANKX and can't quite get it to do what I want.

 

My data is structed as so...

IDDateClosedOwner
15/28/2021Bob
25/29/2021George
36/1/2021George
46/1/2021Frank
56/1/2021Frank

 

Thanks in advance for any help you can provide!

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

One way to do this:

 

 

Top Owner = 
VAR Summary =
    SUMMARIZE (
        FILTER (
            Table1,
            Table1[DateClosed] = TODAY () && NOT ( ISBLANK ( Table1[Owner] ) )
        ),
        Table1[Owner],
        "@Cnt", COUNT ( Table1[ID] )
    )
VAR MaxCnt = MAXX ( Summary, [@Cnt] )
VAR CntText = " (" & FORMAT ( MaxCnt, "0" ) & ")"
VAR TopOwners = FILTER ( Summary, [@Cnt] = MaxCnt )
RETURN
    IF (
        COUNTROWS ( TopOwners ) > 1,
        "TIE - " & CONCATENATEX ( TopOwners, Table1[Owner], " and " ) & CntText,
        MAXX ( TopOwners, Table1[Owner] ) & CntText
    )

 

 

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

One way to do this:

 

 

Top Owner = 
VAR Summary =
    SUMMARIZE (
        FILTER (
            Table1,
            Table1[DateClosed] = TODAY () && NOT ( ISBLANK ( Table1[Owner] ) )
        ),
        Table1[Owner],
        "@Cnt", COUNT ( Table1[ID] )
    )
VAR MaxCnt = MAXX ( Summary, [@Cnt] )
VAR CntText = " (" & FORMAT ( MaxCnt, "0" ) & ")"
VAR TopOwners = FILTER ( Summary, [@Cnt] = MaxCnt )
RETURN
    IF (
        COUNTROWS ( TopOwners ) > 1,
        "TIE - " & CONCATENATEX ( TopOwners, Table1[Owner], " and " ) & CntText,
        MAXX ( TopOwners, Table1[Owner] ) & CntText
    )

 

 

Thank you, thank you, thank you!!

 

This is amazing! The measure is working just as I had hoped.

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.

Top Solution Authors