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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ghaines
Resolver I
Resolver I

Best way to approach some data

I'm working with some data that records a primary failure reason ID in one column, and other failure reason IDs as CSV in another column.  The primary failure reason may or may not be represented in the other failure reason column.

 

My desired outcome is to calculate in DAX Count(VALUES(Transaction_ID)), meaning when there is no filter on failure reasons you will just get the transaction count, so I want to expand the failure reason column while especially preserving the primary failure reason.  So I'd want something like

 

Transaction IDPrimary Failure ReasonFailure Reason
133, 4

->

Transaction IDFailure Reasons
13
14

 

 

and

 

Transaction IDPrimary Failure ReasonFailure Reason
134,5 

->

Transaction IDFailure Reasons
13
14
15

 

Preserving which reason is the primary reason is on the wishlist but not necessarily needed.

 

My solution so far is to transform Failure Reason to a list, combine with primary failure as a one element list, resolve to a unique list, and then expand to rows.  Is there a more efficient solution, or one that would more naturally identify the primary failure reason?

 

Thanks in advance.

1 ACCEPTED SOLUTION
spinfuzer
Solution Sage
Solution Sage

You could

List.RemoveItems(Text.Split([Failure Reason], ","), {[Primary Failure Reason]})

Then add a suffix to the primary reason like ":P"

Combine into a list, split to new rows, split by ":" into columns.

The rows with the "P" in the new column are the primary reasons.

View solution in original post

3 REPLIES 3
AlienSx
Super User
Super User

Hello, @ghaines your current approach seems good to me. But if you like complications then try this

    to_list = List.Buffer(Table.ToList(Source, (x) => x)),
    txform = Table.FromRecords(
        List.TransformMany(
            to_list,
            (x) => List.Distinct({Text.From(x{1})} & Splitter.SplitTextByDelimiter(",")(x{2})),
            (id, reason) => [Transaction ID = id{0}, Failure Reason = reason]
        )
    )
spinfuzer
Solution Sage
Solution Sage

You could

List.RemoveItems(Text.Split([Failure Reason], ","), {[Primary Failure Reason]})

Then add a suffix to the primary reason like ":P"

Combine into a list, split to new rows, split by ":" into columns.

The rows with the "P" in the new column are the primary reasons.

And with this I could reliably set where the primary failure reason appears.  Thanks!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.