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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
SecretChimpanze
Frequent Visitor

Extracting unique values with a condition

Hi,

 

I have a column with text that looks something like this:

 

Fixed-Fixed-Postpaid-Fixed-OMB-OMB

 

Is there a formula that will return only unique values in between the dashes (-)? 

 

Required: Fixed-Postpaid-Fixed-OMB

 

1 ACCEPTED SOLUTION

Hi @SecretChimpanze 
Apologies, I was outside the office when I shared the solution. 

Yes this is a calculated column but its seems that you have some blank cells. Just modify as follows.

 

NewColumn =
VAR String = TableName[ColumnName]
VAR Items =
    SUBSTITUTE ( String, "-", "|" )
VAR Length =
    COALESCE ( PATHLENGTH ( Items ), 1 )
VAR T1 =
    GENERATESERIES ( 1, Length, 1 )
VAR T2 =
    ADDCOLUMNS ( T1, "@Item", PATHITEM ( Items, [Value] ) )
VAR T3 =
    DISTINCT ( SELECTCOLUMNS ( T2, "@@Item", [@Item] ) )
RETURN
    CONCATENATEX ( T3, [@@Item], "-", [@@Item], ASC )

 

 

View solution in original post

6 REPLIES 6
tamerj1
Super User
Super User

Hi @SecretChimpanze 

please try

NewColumn =
VAR String = TableName[ColumnName]
VAR Items =
    SUBSTITUTE ( String, "-", "|" )
VAR Length =
    PATHLENGTH ( Items )
VAR T1 =
    GENERATESERIES ( 1, Length, 1 )
VAR T2 =
    ADDCOLUMNS ( T1, "@Item", PATHITEM ( Items, [Value] ) )
VAR T3 =
    DISTINCT ( SELECTCOLUMNS ( T2, "@@Item", [@Item] ) )
RETURN
    CONCATENATEX ( T3, [@@Item], "-", [@@Item], ASC )

Thanks for this. Can I use this code via "New Column"? I did that and got this error 

"The arguments in GenerateSeries function cannot be blank"

Hi @SecretChimpanze 
Apologies, I was outside the office when I shared the solution. 

Yes this is a calculated column but its seems that you have some blank cells. Just modify as follows.

 

NewColumn =
VAR String = TableName[ColumnName]
VAR Items =
    SUBSTITUTE ( String, "-", "|" )
VAR Length =
    COALESCE ( PATHLENGTH ( Items ), 1 )
VAR T1 =
    GENERATESERIES ( 1, Length, 1 )
VAR T2 =
    ADDCOLUMNS ( T1, "@Item", PATHITEM ( Items, [Value] ) )
VAR T3 =
    DISTINCT ( SELECTCOLUMNS ( T2, "@@Item", [@Item] ) )
RETURN
    CONCATENATEX ( T3, [@@Item], "-", [@@Item], ASC )

 

 

Thank you so much, you have made my day/week/month! I have been scouring the internet for almost a week and have not been able to find a solution. 

amitchandak
Super User
Super User

@SecretChimpanze , In Power Query Refer TextBetweenDelimiters, Also use relative position

 

refer example 3- https://docs.microsoft.com/en-us/powerquery-m/text-betweendelimiters#example-3

 

How to use in a similar video

Text Before Delimiter and Text After Delimiter: https://youtu.be/oGY4RoPKDOE

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

This is what I need but unfortunately I am unable to use this method as mine is a calculated column

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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