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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply

Comma Separated Values

Hi all - I need to go from this:

Report IDExaminations
57818FCNRTJ
53863ZANAE,IBIOPB,IBILXD,FPTCH
50320FNVRK
31285UFOOLJ
75614UGMDCI
70578UNECKN
47734CLUNGB
30357ULIVEB
52545CBONEB
46729IURRBS
68719ICHOSD
32829IGSJXG
59756UHANRJ
78302IASDRD,USPUCI
38219FUREH
74123UNECKN
38429FINJTJ,FUPLR
56246ZZSPICC
37045IURDR,ZANAE,IURRRS
56017ZCONS
52414UDRAID
41634INEPXG
80000UGMDCI
55208FLOLL,FINJTJ
76559INEPXG
79946FHIPR,FINTJ
32153UANKRJ
52167FJSHR
70130IAVEME

 

to this:

 

Report IDExaminations
57818FCNRTJ
53863ZANAE
53863IBIOPB
53863IBILXD
53863FPTCH
31285UFOOLJ
75614UGMDCI
70578UNECKN
47734CLUNGB
30357ULIVEB
52545CBONEB
46729IURRBS
68719ICHOSD
32829IGSJXG
59756UHANRJ
78302IASDRD
78302USPUCI
38219FUREH
74123UNECKN
38429FINJTJ
38429FUPLR
56246ZZSPICC
37045IURDR
37045ZANAE
37045IURRRS
56017ZCONS
52414UDRAID
41634INEPXG
80000UGMDCI
55208FLOLL
55208FINJTJ
76559INEPXG
79946FHIPR
79946FINTJ
32153UANKRJ
52167FJSHR
70130IAVEME

 

Essentially splitting the examinations column into separate rows, using Report ID as identifier.  I cannont do this in Power Query, as the column I'm using is a calculated column based on a complicated Lookup, designed to fetch these values in the first instance.

I either need to somehow create a new table with these split values, or find a way to count each individual exam as at some point I'm going to need to present this on a chart (by month) to show just how many exams (individually) have occurred.

 

Your help is always appreciated!

 

Sample Data 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Creative_tree88 

 

You can make use of PATHITEM and then some crossjoins.

 

-calculated table

DAXSplit =
VAR _Path =
    --add a pathitem column by substituting commas with pipes
    ADDCOLUMNS (
        'Table',
        "@PathItem", SUBSTITUTE ( 'Table'[Examinations], ",", "|" )
    )
VAR _MaxLength =
    --get the overall max path length
    MAXX (
        ADDCOLUMNS ( _Path, "@PathLength", PATHLENGTH ( [@PathItem] ) ),
        [@PathLength]
    )
VAR _Crossjoined =
    CROSSJOIN ( _Path, GENERATESERIES ( 1, _MaxLength, 1 ) )
VAR _ExamItem =
    FILTER (
        ADDCOLUMNS (
            _Crossjoined,
            "Exam Item", PATHITEM ( [@PathItem], [Value], TEXT )
        ),
        NOT ( ISBLANK ( [Exam Item] ) )
    )
RETURN
    SELECTCOLUMNS (
        _ExamItem,
        "Report ID", [Report ID],
        "Examinations", [Examinations],
        [Exam Item]
    )

danextian_0-1734699113838.png

Please see the attached sample pbix.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Creative_tree88 ,

Using Power Query makes it easy to accomplish your needs.

vzhouwenmsft_0-1735009309280.png

vzhouwenmsft_1-1735009327854.png

Final output

vzhouwenmsft_2-1735009352042.png

 

Best Regards

danextian
Super User
Super User

Hi @Creative_tree88 

 

You can make use of PATHITEM and then some crossjoins.

 

-calculated table

DAXSplit =
VAR _Path =
    --add a pathitem column by substituting commas with pipes
    ADDCOLUMNS (
        'Table',
        "@PathItem", SUBSTITUTE ( 'Table'[Examinations], ",", "|" )
    )
VAR _MaxLength =
    --get the overall max path length
    MAXX (
        ADDCOLUMNS ( _Path, "@PathLength", PATHLENGTH ( [@PathItem] ) ),
        [@PathLength]
    )
VAR _Crossjoined =
    CROSSJOIN ( _Path, GENERATESERIES ( 1, _MaxLength, 1 ) )
VAR _ExamItem =
    FILTER (
        ADDCOLUMNS (
            _Crossjoined,
            "Exam Item", PATHITEM ( [@PathItem], [Value], TEXT )
        ),
        NOT ( ISBLANK ( [Exam Item] ) )
    )
RETURN
    SELECTCOLUMNS (
        _ExamItem,
        "Report ID", [Report ID],
        "Examinations", [Examinations],
        [Exam Item]
    )

danextian_0-1734699113838.png

Please see the attached sample pbix.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Kedar_Pande
Super User
Super User

@Creative_tree88 

Create a new table:

Examinations_Split = 
VAR AddRows =
ADDCOLUMNS (
'YourOriginalTable',
"Examination",
PATHITEM('YourOriginalTable'[Examinations], 1)
)
RETURN
UNION(
SELECTCOLUMNS( AddRows, "Report ID", 'YourOriginalTable'[Report ID], "Examination", [Examination] ),
ADDCOLUMNS(
'YourOriginalTable',
"Examination",
PATHITEM('YourOriginalTable'[Examinations], 2)
)
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Bibiano_Geraldo
Super User
Super User

Hi @Creative_tree88 ,

You can achieve the desired result by creating a new calculated table using the following DAX:

NewTable = 
VAR Separator = "|"
RETURN
SELECTCOLUMNS(
    GENERATE(
        'YourOriginalTable',
        VAR ExaminationsList = SUBSTITUTE('YourOriginalTable'[Examinations], ",", Separator)
        RETURN 
        SELECTCOLUMNS(
            GENERATESERIES(1, LEN(ExaminationsList) - LEN(SUBSTITUTE(ExaminationsList, Separator, "")) + 1),
            "Report ID2", [Report ID],
            "SplitValue", PATHITEM(ExaminationsList, [Value], TEXT)
        )
    ),
    "Report ID2", [Report ID2],
    "SplitValue", [SplitValue]
)


Your output will look like this:

Bibiano_Geraldo_0-1734698961750.png

 

 

@Bibiano_Geraldo that works well.  Is there any way I can now bring the rest of the dataset into this new table (or somehow lookup from original table?), to effectively create a copy of the original data (with ALL the fields) but with these exams now sitting (correctly) on one row??

You can use this DAX:

NewTable = 
VAR Separator = "|"
RETURN
    GENERATE(
        'YourOriginalTable',
        VAR ExaminationsList = SUBSTITUTE('YourOriginalTable'[Examinations], ",", Separator) 
        RETURN 
            SELECTCOLUMNS(
                GENERATESERIES(1, LEN(ExaminationsList) - LEN(SUBSTITUTE(ExaminationsList, Separator, "")) + 1),
                "Examination", PATHITEM(ExaminationsList, [Value], TEXT)
            )
    )

 

Your output will look like this:

Bibiano_Geraldo_0-1734702432814.png

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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