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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
JorgenMaass
New Member

Remove reoccurring text elements in column (text)

I have a table with a column "Indata" (type text). Each row consist of a set of comma separated "textelements".
For some of the rows the same textelement occurs more than once. 
I would like to get help to find the DAX expression to filter out the copies.


JorgenMaass_0-1632251532868.png

1 ACCEPTED SOLUTION

@JorgenMaass Correct, that was the intention!! Here is the fully script:

Result Column =
  VAR __Text = SUBSTITUTE([Indata],", ","|")
  VAR __Count = PATHLENGTH(__Text)
  VAR __Table = 
    DISTINCT(
      SELECTCOLUMNS(
        ADDCOLUMNS(
          GENERATESERIES(1,__Count,1),
          "__Word",PATHITEM(__Text,[Value])
        ),
        "__Word",[__Word]
      )
    )
RETURN
  CONCATENATEX(__Table,[__Word],", ")


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Community Champion
Community Champion

@JorgenMaass Here's one way:

Result Column =
  VAR __Text = SUBSTITUTE([Indata],", ","|")
  VAR __Count = PATHLENGTH(__Text)
  VAR __Table = 
    DISTINCT(
      SELECTCOLUMNS(
        ADDCOLUMNS(
          GENERATE(1,__Count,1),
          "__Word",PATHITEM(__Table,[Value])
        ),
        "__Word",[__Word]
      )
    )
RETURN
  CONCATENATEX(__Table,[__Word],", ")


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler thanks for a quick reply!
But I dont get it to work:

 

JorgenMaass_0-1632256312711.png

 

@JorgenMaass Whoops, used the wrong variable. Can't believe that was the only issue, I winged it.

Result Column =
  VAR __Text = SUBSTITUTE([Indata],", ","|")
  VAR __Count = PATHLENGTH(__Text)
  VAR __Table = 
    DISTINCT(
      SELECTCOLUMNS(
        ADDCOLUMNS(
          GENERATE(1,__Count,1),
          "__Word",PATHITEM(__Text,[Value])
        ),
        "__Word",[__Word]
      )
    )
RETURN
  CONCATENATEX(__Table,[__Word],", ")


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thx again. Still dont get it to work.
2 errors: 
* [Value] is an unknown variable
* GENERATE(1,     Parameter is incorrent type

Best regards

JorgenMaass_0-1632257389969.png

 

@Greg_Deckler it works if I use GENERATESERIES() instead of GENERATE.
 

@JorgenMaass Correct, that was the intention!! Here is the fully script:

Result Column =
  VAR __Text = SUBSTITUTE([Indata],", ","|")
  VAR __Count = PATHLENGTH(__Text)
  VAR __Table = 
    DISTINCT(
      SELECTCOLUMNS(
        ADDCOLUMNS(
          GENERATESERIES(1,__Count,1),
          "__Word",PATHITEM(__Text,[Value])
        ),
        "__Word",[__Word]
      )
    )
RETURN
  CONCATENATEX(__Table,[__Word],", ")


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors