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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
sshanssun
Helper I
Helper I

Calculated Column Help

Hi, I have a 'calculated column A' from a table with multiple or same values separated by comma. I need another 'calculated column B' to show whether that 'calculated column A' is single, multiple or others, example is provided below, appreciate your help:

 

Table1:

Calculated Column ACalculated Column B
,Elix ASingle
,Elix A,Elix B,Multiple
,Elix B,Single
,Elix A,Elix C,Elix D,Multiple
,Elix A,ElixA,Single
..Others
,Others
,,,,,Others

showed in a picture as below, 

sshanssun_0-1744230238796.png

 

Thanks in advance for the support

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @sshanssun,

Thank you for reaching out in Microsoft Community Forum.

Thank you @lbendlin  for the helpful response.

Please use below DAX for required output;

Calculated Column B =
VAR a = SUBSTITUTE([Calculated Column A], ",", "|")
VAR PathLength = PATHLENGTH(a)
VAR AllItems =
ADDCOLUMNS (
GENERATESERIES(1, PathLength),
"v", PATHITEM(a, [Value])
)
VAR CleanItems =
FILTER ( AllItems, NOT ISBLANK([v]) && [v] <> "" )
VAR DistinctItems =
SUMMARIZE ( CleanItems, [v] )
VAR HasBlanks =
COUNTROWS(AllItems) > COUNTROWS(CleanItems)
VAR DistinctCount = COUNTROWS(DistinctItems)
RETURN
SWITCH (
TRUE(),
DistinctCount = 0, "Others",
DistinctCount = 1 && NOT HasBlanks, "Single",
TRUE, "Multiple"
)

 

Please continue using Microsoft community forum.

If you found this post helpful, please consider marking it as "Accept as Solution" and give it a 'Kudos'. if it was helpful. help other members find it more easily.

Regards,
Pavan.

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

Same as before. You need to use PATH functions.

Calculated Column B =
VAR a =
    SUBSTITUTE ( [Calculated Column A], ",", "|" )
VAR b =
    COALESCE (
        COUNTROWS (
            SUMMARIZE (
                FILTER (
                    ADDCOLUMNS (
                        GENERATESERIES ( 1, PATHLENGTH ( a ) ),
                        "v", PATHITEM ( a, [Value] )
                    ),
                    [v] > ""
                ),
                [v]
            )
        ),
        0
    )
RETURN
    SWITCH ( b, 0, "Others", 1, "Single", "Multiple" )

lbendlin_0-1744231593686.png

 

"Elix A"  and "ElixA"  are not the same string.

Hi, Thank you so much. I ran into one more issue. My outcome under 'Calculated Column A' with a multiple comma delimiter has different data value which means those could not be found in the original table and hence those were left blanks with commas. for example,

 

If the Calculated Column A has a value of ",Elix A,,," and there is a comma before Elix A and after which means, there are value with a delimiter which is blank and this should be Multiple. I apologize that I didn't specifiy this very cleary when I sent it originally and it is my mistake.

 

Example and expected output table,

 

Calculated Column ACalculated Column B
,Elix AMultiple
Elix A,Elix ASingle
Elix BSingle
Elix B,,,Multiple
,,Others
Elix CSingle
Elix D,Multiple
,Elix D,Elix DMultiple
,Others
Elix A,Elix B,Multiple
Elix D,Elix DSingle

 

table in picture format, 

sshanssun_0-1744288644954.png

 Thank you once again for the help.

Anonymous
Not applicable

Hi @sshanssun,

Thank you for reaching out in Microsoft Community Forum.

Thank you @lbendlin  for the helpful response.

Please use below DAX for required output;

Calculated Column B =
VAR a = SUBSTITUTE([Calculated Column A], ",", "|")
VAR PathLength = PATHLENGTH(a)
VAR AllItems =
ADDCOLUMNS (
GENERATESERIES(1, PathLength),
"v", PATHITEM(a, [Value])
)
VAR CleanItems =
FILTER ( AllItems, NOT ISBLANK([v]) && [v] <> "" )
VAR DistinctItems =
SUMMARIZE ( CleanItems, [v] )
VAR HasBlanks =
COUNTROWS(AllItems) > COUNTROWS(CleanItems)
VAR DistinctCount = COUNTROWS(DistinctItems)
RETURN
SWITCH (
TRUE(),
DistinctCount = 0, "Others",
DistinctCount = 1 && NOT HasBlanks, "Single",
TRUE, "Multiple"
)

 

Please continue using Microsoft community forum.

If you found this post helpful, please consider marking it as "Accept as Solution" and give it a 'Kudos'. if it was helpful. help other members find it more easily.

Regards,
Pavan.

Thank you so much, Pavan. It worked!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors