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 August 31st. Request your voucher.

Reply
suman1985
Helper I
Helper I

DAX- To convert a comma delimited string column into a list and filter the Table

Hi All,

I am newbie to DAX. Please help me with your suggestions.

I have a scenario where I have a Input Table with Comma delimited string (Names) and sales Column. Please see Input Table below.

Input Table
S.NoNamesAmount
1a,b,c100
2b,c150
3a,c200
4b,d150
5a,c,d50
6d250
7c,d300

I wanted to show a output table as  Distinct Names  and sum of Amount 

EG: name a is at rows 1,3,5 -so , sum(amount) where ever the a exists which is 350.

Now, I wanted to convert this table data to a Result Table as  shown below. 

Result table
Distinct NamesAmount
a350
b400
c800
d750

 

Please create this output table using only DAX.

 

Appreciate the help.

Thanks

Suman

1 ACCEPTED SOLUTION

not sure if i understood you correctly but here 

 

Total Amount = IF(ISFILTERED('Table'[Group]),CALCULATE(SUM(TasksSplit[Amount]),TasksSplit[Group] = MAX('Table'[Group])),SUM(TasksSplit[Amount]))
Ranking = 
IF(
    ISFILTERED('Table'[Group]),
    IF(
        NOT(ISBLANK([Total Amount])),
        CALCULATE(
            RANKX(
                ALLSELECTED(TasksSplit[SingleName]),
                [Total Amount],
                ,
                DESC,
                Dense
            ),
            TasksSplit[Group] = MAX('Table'[Group])
        )
    ),RANKX(
                ALLSELECTED(TasksSplit[SingleName]),
                [Total Amount],
                ,
                DESC,
                Dense
            )
)

 



annonymous1999_0-1694159415410.png

As you see i am using the group from the main table without any relationships 

annonymous1999_1-1694159446151.png


Final result 

Recording 2023-09-08 093505.gif

View solution in original post

15 REPLIES 15
suman1985
Helper I
Helper I

Hi @eliasayyy 

Thanks for the suggestion .

Unfortunately, I dont want to use Power Query for this scenario. I would rather need this table output within  a single DAX  .

Thanks

suman1985
Helper I
Helper I

Hi @AnthonyGenovese 

 

Thanks for quick response. 

Unfortunately, I cant use the Power Query. Can this be done only in the DAX.

Appreciate the help..

oh i see in that case lets create a new calculated table @suman1985 

NamesSplit = 
VAR MaxNames = CALCULATE(MAXX('Table', LEN('Table'[Names]) - LEN(SUBSTITUTE('Table'[Names], ",", "")) + 1))

RETURN
FILTER(
    GENERATE(
        'Table',
        ADDCOLUMNS(
            GENERATESERIES(1, MaxNames, 1),
            "SingleName", TRIM(PATHITEM(SUBSTITUTE('Table'[Names], ",", "|"), [Value]))
        )
    ),
    NOT(ISBLANK([SingleName]))
)

annonymous1999_0-1694090031878.png

 

RESULT

annonymous1999_1-1694090041669.png

if i help you please accept as solution and leave a kudos



Hi @eliasayyy 

Awesome , it worked.😊.You saved my time..

I have added two more scenarios for this. Please be patient to solve this. Appreciate the help.

Please modify the DAX based on the modified input data.

I have added a group column as shown below input table 

1. Now, I have a group slicer coming from a table INPUT Table and i see now there is no relation exists and wanted to filter this new DAX table with the group slicer with multiple values selected. Output should be same as shown above.

2. And I want to add dynamic ranking based on the slicer selection.

INPUT Table

GroupTasksAmount
Group1a,b,c100
Group2b,c150
Group3a,c200
Group4b,d130
Group5a,c,d50
Group6d250
Group7c,d300
Group1a,d100

 

Result table 
Distinct NamesAmountRank
a4503
b3804
c8002
d8301

Thanks

Ranking =
RANKX(ALLSELECTED(TasksSplit[SingleName]),[Total Amount],,DESC,Dense)

Recording 2023-09-08 093505.gif

 if its solved your issue kindly accept it as solution

Hi @eliasayyy 

Ranking works fine. But can you take the group column as slicer from the input table instead of from the Derived calcualted table.

Thanks

yes just create a relationship between group and group or even better create a dim table wjich is always a great practice  that returns unique values of group and then create a relationship between the two 

annonymous1999_0-1694157805613.png

DimGroup = ALLNOBLANKROW('Table'[Group])

annonymous1999_1-1694157836030.png

 



Thanks for the suggestion @eliasayyy 

Actually, this is one of the visual logic we are implementing on a report which has 7 visuals.

There are 6 slicers and Group slicer is one among them used on the report.  All these 6 slicers are begin taken from the input Data. 

So , I cant create any new dimensions for the Groups as they are already being pulled from the Input data

The requirement I shared is specifically for this visual.

Please include the group slicer from the input data and filter the dax table based on the selcted value from the group slicer.

 

Hope you undersatand and appreciate the continuous help.

 

Thanks

not sure if i understood you correctly but here 

 

Total Amount = IF(ISFILTERED('Table'[Group]),CALCULATE(SUM(TasksSplit[Amount]),TasksSplit[Group] = MAX('Table'[Group])),SUM(TasksSplit[Amount]))
Ranking = 
IF(
    ISFILTERED('Table'[Group]),
    IF(
        NOT(ISBLANK([Total Amount])),
        CALCULATE(
            RANKX(
                ALLSELECTED(TasksSplit[SingleName]),
                [Total Amount],
                ,
                DESC,
                Dense
            ),
            TasksSplit[Group] = MAX('Table'[Group])
        )
    ),RANKX(
                ALLSELECTED(TasksSplit[SingleName]),
                [Total Amount],
                ,
                DESC,
                Dense
            )
)

 



annonymous1999_0-1694159415410.png

As you see i am using the group from the main table without any relationships 

annonymous1999_1-1694159446151.png


Final result 

Recording 2023-09-08 093505.gif

Thanks @eliasayyy 

I have to really thanks for   answering my queries with great patience.We are very close to the required result.

It is working for single select value on slicer.

Its my fault, I didnt explain that slicer should be a multi select valued.

I have more than 1 slicer then result table should filter based on the 3 slicers selected values as shown on screenshot .
Please modify DAX for multiselect on all slicers (ALL, Mutiselect)  .It should work for both

suman1985_0-1694162959345.png

Input Data:

BrandSubEventTasksAmount
AFreeGroup1a,b,c100
ANormalGroup2b,c150
AFreeGroup3a,c200
BNormalGroup4b,d130
BFreeGroup5a,c,d50
CFreeGroup6d250
CFreeGroup7c,d300
DNormalGroup1a,d100

can you show me what slicer you are using please

Hi @eliasayyy 

 

I am using group Slicer from the Input table. Please see below screenshot. 

Earlier input table has only Tasks and amount. I have added Group column now and want to filter the result table with Group Column and rank the table accordingly.

suman1985_0-1694155440798.png

Thanks

AnthonyGenovese
Resolver III
Resolver III

The way I would do it - I would first need a table with all your distinct names. I would do that step in Power Query.  once you have your table of distinct names, the measure to create your amount measure is pretty straight forward.  

 

You will do something like
calculate(sum(amount), Containstring('InputTable'[Names],selectedvalue('NewPowerQueryTable'[Names])

 

https://dax.guide/containsstring/

 

If this post was helpful, please kudos or accept the answer as a solution.
~ Anthony Genovese
Need more PBI help? PM me for affordable, dedicated training or consultant recomendations!

Hi @AnthonyGenovese 

Thanks for the suggestion.

 

Is there a way we can write DAX with not to have a Slicer for the Distinct Names.? I wanted everything to be wrapped within the single DAX with all the totals summed up by the Names.

 

Thanks

hello @suman1985 if you are able to use powerquery , right click on the column with commas and choose split by delmiter , 

annonymous1999_0-1694089133939.png


press on advanced and select by rows

annonymous1999_1-1694089167104.png

 

result

annonymous1999_2-1694089185194.png

now in dax just make a simple sum('Table'[Amount])

annonymous1999_3-1694089240656.png

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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