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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Bren_L1
New Member

Sort concatenated look up values

Hi, 

I have concatenated two lookup fields from different tables into a master table, but am getting different combinations of the same values. I cant merge or append these tables unfortunately so trying to resolve outside of query editor. 

I have been trying to sort them to resolve this issue but cant get the result i need unfortunately, row 1 & 2 specifcally need to be the same per the required result field below. 

Example of data 

Column1Column2Concatenated fieldRequired result
AAABBBAAA,BBBAAA,BBB
BBBAAABBB,AAAAAA,BBB
CCCCCCCCC,CCCCCC,CCC
DDDDDDDDD,DDDDDD,DDD
EEEDDDEEE,DDD

EEE,DDD

 

Any assistance would be greatly appreciated. 

Thanks, 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Bren_L1 ,

 

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
var _column1=
SELECTCOLUMNS('Table',"Column1",[Column1])
var _column2=
SELECTCOLUMNS('Table',"Column2",[Column2])
var _table=
DISTINCT(
UNION(
    _column1,_column2))
return
ADDCOLUMNS(
    _table,"rank",RANKX(_table,[Column1],,ASC))

vyangliumsft_0-1708313891163.png

2. Create calculated column.

Rank_index =
var _rank1=
MAXX(
    FILTER(
        'Table 2','Table 2'[Column1]=EARLIER('Table'[Column1])),[rank])
var _rank2=
MAXX(
    FILTER(
        'Table 2','Table 2'[Column1]=EARLIER('Table'[Column2])),[rank])
return
IF(
    _rank1<=_rank2,
    [Column1]&","&[Column2],
    [Column2]&","&[Column1])

3. Result:

vyangliumsft_1-1708313891165.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @Bren_L1 ,

 

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
var _column1=
SELECTCOLUMNS('Table',"Column1",[Column1])
var _column2=
SELECTCOLUMNS('Table',"Column2",[Column2])
var _table=
DISTINCT(
UNION(
    _column1,_column2))
return
ADDCOLUMNS(
    _table,"rank",RANKX(_table,[Column1],,ASC))

vyangliumsft_0-1708313891163.png

2. Create calculated column.

Rank_index =
var _rank1=
MAXX(
    FILTER(
        'Table 2','Table 2'[Column1]=EARLIER('Table'[Column1])),[rank])
var _rank2=
MAXX(
    FILTER(
        'Table 2','Table 2'[Column1]=EARLIER('Table'[Column2])),[rank])
return
IF(
    _rank1<=_rank2,
    [Column1]&","&[Column2],
    [Column2]&","&[Column1])

3. Result:

vyangliumsft_1-1708313891165.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thanks this worked as required, really appreciate the assistance 🙂

Greg_Deckler
Community Champion
Community Champion

@Bren_L1 Try:

Column = 
  VAR __Values = { [Column1], [Column2] }
  VAR __Result = CONCANTENATEX( __Values, [Value], ",", [Value])
RETURN
  __Result


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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors