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.
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.
Solved! Go to 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],", ")
@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],", ")
@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],", ")
@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 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],", ")
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
96 | |
81 | |
74 | |
66 |
User | Count |
---|---|
126 | |
106 | |
105 | |
86 | |
72 |