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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors