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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Devesh
Frequent Visitor

split the amount value using comma separated value column dax

Hi All,

 

I am struggling with this simple problem.

My data set:

nameamount
a500
b500
c,d500
e,f,g600
h1000
I,j,k,l1000

 

The output I want:

nameamount
a500
b500
c250
d250
e200
f200
g200
h1000
i250
j250
k250
l250

 

Here simple,

I am splitting the amount by the number of values I can find in the name column.

I can only use DAX as my dataset is a Calculated Table. Please help.

1 ACCEPTED SOLUTION

Hi @Devesh ,

 

My error, did not notice the last part that you asked for the split check the formula and PBIX revised:

 

Word List = 
VAR SplitByCharacter = ","
VAR Table0 =
    ADDCOLUMNS (
        GENERATE (
            Unpivot,
            VAR TokenCount =
                PATHLENGTH ( SUBSTITUTE ( Unpivot[name], SplitByCharacter, "|" ) )
            RETURN
                GENERATESERIES ( 1, TokenCount )
        ),
        "NameSplit", PATHITEM ( SUBSTITUTE ( Unpivot[name], SplitByCharacter, "|" ), [Value] ),
        "Numberofwords",
            LEN ( Unpivot[name] ) - LEN ( SUBSTITUTE ( Unpivot[name], ",", "" ) ) + 1
    )
RETURN
  SELECTCOLUMNS(  Table0, "AMount", Divide(Unpivot[amount], [Numberofwords]), "Name", [NameSplit])

 

MFelix_0-1641977768820.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
MFelix
Super User
Super User

Hi @Devesh ,

 

Using this post you can do the following calculation:

 

Word List = 
VAR SplitByCharacter = ","
VAR Table0 =
    ADDCOLUMNS (
        GENERATE (
            Unpivot,
            VAR TokenCount =
                PATHLENGTH ( SUBSTITUTE (Unpivot[name], SplitByCharacter, "|" ) )
            RETURN
                GENERATESERIES ( 1, TokenCount )
        ),
        "NameSplit", PATHITEM ( SUBSTITUTE ( Unpivot[name], SplitByCharacter, "|" ), [Value] )
    )
RETURN
  SELECTCOLUMNS(  Table0, "AMount", Unpivot[amount], "Name", [NameSplit])

 

MFelix_0-1641916338806.png

 

PBIX file attach.

 

 


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





Devesh
Frequent Visitor

Hi,

The amount does not get divided using the formula you posted. It just copies the amount into all CSV values.

Hi @Devesh ,

 

My error, did not notice the last part that you asked for the split check the formula and PBIX revised:

 

Word List = 
VAR SplitByCharacter = ","
VAR Table0 =
    ADDCOLUMNS (
        GENERATE (
            Unpivot,
            VAR TokenCount =
                PATHLENGTH ( SUBSTITUTE ( Unpivot[name], SplitByCharacter, "|" ) )
            RETURN
                GENERATESERIES ( 1, TokenCount )
        ),
        "NameSplit", PATHITEM ( SUBSTITUTE ( Unpivot[name], SplitByCharacter, "|" ), [Value] ),
        "Numberofwords",
            LEN ( Unpivot[name] ) - LEN ( SUBSTITUTE ( Unpivot[name], ",", "" ) ) + 1
    )
RETURN
  SELECTCOLUMNS(  Table0, "AMount", Divide(Unpivot[amount], [Numberofwords]), "Name", [NameSplit])

 

MFelix_0-1641977768820.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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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