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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Creating calculated column based on comma separated values on a column

Hi,

 

Still learning Power BI here, and I have currently encountered one challenge that I can't seem to solve. Hoping someone can enlighten me on how to address this:

 

I have 2 tables:

1. Records table - contains 2 columns: record ID and selected values that are comma separated

2. Max score table - contains 2 columns: selection and its corresponding score

 

What I am trying to achieve is to create a new column called total max score on the records table, whose values will depend on what selections are in that particular record. For example, if record ID001 has the selection A,B and A has score of 300, and B has a score of 100, the total max score for ID001 will be 400.

 

Unfortunately, with my still limited knowledge in DAX or Power Query, I am not able to provide any code so far, and hoping someone can provide some hints on how I can do this.

 

Records Table

Record IDSelected
ID001A,B
ID002A
ID003A,C

 

Max Scores Table

 

SelectionsScore
A300
B100
C500

 

Desired output for Records Table:

 

Record IDSelectedMax Score
ID001A,B400
ID002A300
ID003A,C800

 

Thanks in advance for any help!

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous ,

 

You can achieve this column by using the following syntax:

MAximumScore = 
var RecordIDValue = Records[Record ID]
VAR SplitByCharacter = ","
var table1 =

ADDCOLUMNS (
    ADDCOLUMNS (
        GENERATE (
            Records,
            VAR TokenCount =
                PATHLENGTH ( SUBSTITUTE ( Records[Selected], SplitByCharacter, "|" ) )
            RETURN
                GENERATESERIES ( 1, TokenCount )
        ),
        "Word", PATHITEM ( SUBSTITUTE ( Records[Selected], SplitByCharacter, "|" ), [Value] )
    ),
    "@MAXIMUMSCORE",
        MAXX (
            FILTER ( ALL ( 'MAx Scores' ), 'MAx Scores'[Selections] = [Word] ),
            'MAx Scores'[Score]
        )
)

return
SUMX(FILTER(table1, Records[Record ID] =  RecordIDValue), [@MAXIMUMSCORE])

MFelix_0-1631372960047.png

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thanks @MFelix and @v-chenwuz-msft! The solutions you both provided fulfilled my requirement. There are really different ways to solve a requirement in Power BI, as long as you have a good understanding of the functions. I hope to get there soon!

 

As I only managed to go online today, I will credit the solution to Miguel as his post came first. Thanks heaps for the help guys!

v-chenwuz-msft
Community Support
Community Support

Hi @roosechua,

 

There two ways, DAX and power query

DAX expression:

1 select the Selected column in power query editor and split this column by delimiter and click ok

vchenwuzmsft_0-1631497154284.png

 

2 close and apply in the upper left corner.

3 create a new column with this measure

Max Socore =

var _1 = LOOKUPVALUE('Max Scores'[Score],'Max Scores'[Selections],'Records'[Selected.1])

var _2 = LOOKUPVALUE('Max Scores'[Score],'Max Scores'[Selections],'Records'[Selected.2])

RETURN

_1+_2

4 Result:

vchenwuzmsft_1-1631497154289.png

 

 

Power Query

1 Go to the power query editor and create a new column in the Records table via the Custom Column under Add Column tab.

 

2 Enter the blow formula:

= List.Sum(

    List.ReplaceMatchingItems(

        Text.Split([Selected],","),

        Table.ToRows(#"Max Scores")

    )

)

 

3 The result:

vchenwuzmsft_2-1631497154291.jpeg

 

 

 

Best Regards

Community Support Team _ chenwu zhu

 

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

MFelix
Super User
Super User

Hi @Anonymous ,

 

You can achieve this column by using the following syntax:

MAximumScore = 
var RecordIDValue = Records[Record ID]
VAR SplitByCharacter = ","
var table1 =

ADDCOLUMNS (
    ADDCOLUMNS (
        GENERATE (
            Records,
            VAR TokenCount =
                PATHLENGTH ( SUBSTITUTE ( Records[Selected], SplitByCharacter, "|" ) )
            RETURN
                GENERATESERIES ( 1, TokenCount )
        ),
        "Word", PATHITEM ( SUBSTITUTE ( Records[Selected], SplitByCharacter, "|" ), [Value] )
    ),
    "@MAXIMUMSCORE",
        MAXX (
            FILTER ( ALL ( 'MAx Scores' ), 'MAx Scores'[Selections] = [Word] ),
            'MAx Scores'[Score]
        )
)

return
SUMX(FILTER(table1, Records[Record ID] =  RecordIDValue), [@MAXIMUMSCORE])

MFelix_0-1631372960047.png

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.