To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi everyone, i have a problem with DAX syntaxt.
I would like to concatenate 2 columns into a new column but with a specific order. Let's make an example.
Suppose that we have into table A the columns: Names, Ages
Names | Ages |
Lucas, Walter, Marius Uan, Alex | 23,25,45,44 |
Debora | 21 |
I would like to calculate a new column called "Names and Ages" like that:
Lucas(23), Walter(25), Marius Uan(45), Alex(44)
Debora(21)
Could someone help me?
Thanks a lot in advice ❤️
Solved! Go to Solution.
@LordAssalt00 Try this:
Column =
VAR __NamesTable = SUBSTITUTE(SUBSTITUTE([Names], " ", ""),",", "|")
VAR __AgesTable = SUBSTITUTE(SUBSTITUTE([Ages], " ", ""),",", "|")
VAR __Length = PATHLENGTH(__NamesTable)
VAR __Table =
ADDCOLUMNS(
GENERATESERIES(1, __Length, 1),
"__Text", PATHITEM( __NamesTable, [Value]) & "(" & PATHITEM( __AgesTable, 1) & ")"
)
VAR __Result = CONCATENATEX( __Table, [__Text], ", " )
RETURN
__Result
@LordAssalt00 Try this:
Column =
VAR __NamesTable = SUBSTITUTE(SUBSTITUTE([Names], " ", ""),",", "|")
VAR __AgesTable = SUBSTITUTE(SUBSTITUTE([Ages], " ", ""),",", "|")
VAR __Length = PATHLENGTH(__NamesTable)
VAR __Table =
ADDCOLUMNS(
GENERATESERIES(1, __Length, 1),
"__Text", PATHITEM( __NamesTable, [Value]) & "(" & PATHITEM( __AgesTable, 1) & ")"
)
VAR __Result = CONCATENATEX( __Table, [__Text], ", " )
RETURN
__Result
User | Count |
---|---|
14 | |
11 | |
6 | |
6 | |
5 |
User | Count |
---|---|
29 | |
17 | |
11 | |
7 | |
5 |