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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Maxwell
Frequent Visitor

Question On Delimiters

I made a measures that combines all of the players in a golf league. I am filtering by handicap. My current Measure uses 'and' as a delimiter if there are 2 players and ',' if there are more. Here is my current Measure:

Measure =
CONCATENATEX(
DISTINCT(
Table[Player]
),
Table[Player],
IF(
DISTINCTCOUNT(
Table[Player]
)=2,
" and ",
", "
)
)

Is there a way to make it so if there are more than 2 players, the delimiter would be ',' except for the last delimiter. For example:

Instead of: Bob, John, Timmy, Ross

I Want: Bob, John, Timmy and Ross

 

Any help is appreciated!

-Maxwell

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi Maxwell

 

Here is one way you could do it, and variations on this are certainly possible 🙂

To make this work, you do need a well-defined ordering of Players to determine which one appears after "and".

In the measure below, I used the "max" Player (based on text sorting) as the Player to appear after "and".

 

Measure =
VAR Players =
    DISTINCT ( Table[Player] )
VAR NumPlayers =
    COUNTROWS ( Players )
VAR LastPlayer =
    MAXX ( Players, Table[Player] )
VAR PlayersExceptLast =
    EXCEPT ( Players, { LastPlayer } )
VAR Concatenated =
    CONCATENATEX ( PlayersExceptLast, Table[Player], ", ", Table[Player] )
        & IF ( NumPlayers >= 2, " and " ) & LastPlayer
RETURN
    Concatenated

 

 Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi Maxwell

 

Here is one way you could do it, and variations on this are certainly possible 🙂

To make this work, you do need a well-defined ordering of Players to determine which one appears after "and".

In the measure below, I used the "max" Player (based on text sorting) as the Player to appear after "and".

 

Measure =
VAR Players =
    DISTINCT ( Table[Player] )
VAR NumPlayers =
    COUNTROWS ( Players )
VAR LastPlayer =
    MAXX ( Players, Table[Player] )
VAR PlayersExceptLast =
    EXCEPT ( Players, { LastPlayer } )
VAR Concatenated =
    CONCATENATEX ( PlayersExceptLast, Table[Player], ", ", Table[Player] )
        & IF ( NumPlayers >= 2, " and " ) & LastPlayer
RETURN
    Concatenated

 

 Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Thank you Owen!

Worked like a charm!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.