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
mwjansen
Helper I
Helper I

Data grouping with multiple entries in cells.

In 'Table' table there is a column [Body Part]. The data comes from user entries, and they are allowed to select multiple entries. 

ie Hand, Ankle, Back (the entry form inserts the commas/spaces). 

 

I want to be able to group (or count) each individual body part for use in a visual. 

 

            Body Part

Row     Hand (r), Hand (l), Shoulder (l)

            Ankle (r)

            Leg (l), Hand (r)

            Hand (l), Neck, Back

            Back, Shoulder (r)

 

In this example, I want to be able to show a count of Hand(4), Ankle (1), Leg(1), Neck(1), Back(2), Shoulder(2). 

Not concerned with L or R for this count. 

I tried data grouping, but once I put the first entry into a group (for Hand), I cannot use it in another group (for Shoulder), and thus the Shoulder count would be off. 

 

Is there another way? Some kind of measure I could write? 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@mwjansen create a new table for body parts and use the following DAX. See attached file for reference:

 

Body Parts Count = 
VAR __Count = 
SUMX ( 
    'Table',
    VAR __CurrentRow =  SUBSTITUTE ( 'Table'[Row], "," , "|" )
    VAR __CurrentRowTotalBodyParts = PATHLENGTH ( __CurrentRow )
    VAR __CurrentBodyPartsTable = 
        SELECTCOLUMNS ( 
            ADDCOLUMNS ( 
                GENERATESERIES ( 1, __CurrentRowTotalBodyParts ), 
                "Current Part", PATHITEM ( __CurrentRow, [Value] ) 
            ), 
            "Current Part", [Current Part] 
        )
    VAR __BodyPartsFound =  
    FILTER ( 
        CROSSJOIN ( __CurrentBodyPartsTable, 'Body Parts' ),
        CONTAINSSTRING ( [Current Part], [Body Part] )
    )
    RETURN
       COUNTROWS ( __BodyPartsFound )
    
)
RETURN 
    __Count 



        

 

Result:

 

parry2k_0-1741730130576.png

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

17 REPLIES 17
mwjansen
Helper I
Helper I

hello @v-pgoloju 

I followed the pbix/DAX from parry2k, but when i create the same DAX and table in mine, i get an error:

Calculation error in measure 'Body Parts'[Body Parts Count]: The arguments in GenerateSeries function cannot be blank. 

That's where I'm stuck. 

v-pgoloju
Community Support
Community Support

Hi @mwjansen,

 

Thank you for reaching out to the Microsoft Fabric Forum Community.

 

Just following up to see where you're currently facing challenges in implementing the solution. Are you encountering issues with Power Query or DAX? If you've made any progress or tried a different approach, feel free to share it here we’re happy to assist further.

 

If a solution worked for you, kindly consider marking it as accepted and giving it a thumbs-up to help others in the community benefit as well.

 

Best regards,
Prasanna Kumar

v-pgoloju
Community Support
Community Support

Hi @mwjansen,

 

Just a gentle reminder  has your issue been resolved? If so, we’d be grateful if you could mark the solution that worked as Accepted Solution, or feel free to share your own if you found a different fix.

This not only closes the loop on your query but also helps others in the community solve similar issues faster.

Thank you for your time and feedback!

 

Best,

Prasanna Kumar

hi @v-pgoloju , still working on a solution for this. 

v-pgoloju
Community Support
Community Support

Hi @mwjansen,

 

We wanted to kindly check in to see if everything is working as expected after trying the suggested solution. If there’s anything else we can assist with, please don’t hesitate to ask.

If the issue is resolved, we’d appreciate it if you could mark the helpful reply as Accepted Solution  it helps others who might face a similar issue.

 

Warm regards,

Prasanna Kumar

v-pgoloju
Community Support
Community Support

Hi @mwjansen,

 

Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.

If the response addressed your query, kindly mark it as Accepted Solution and click Yes if you found it helpful — this will benefit others in the community as well.

 

Best regards,

Prasanna Kumar

parry2k
Super User
Super User

@mwjansen not sure why, but you should follow what is in the attached pbix file. Not sure what else to tell you.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k I'll keep plugging at it. Thank you for your help. 

Ashish_Mathur
Super User
Super User

Hi,

In Power Query, split data of that column into rows and remove the information within brackets.  Now you should be able to use this measure

Measure = countrows(Data)

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@mwjansen are you adding it as a column or a measure? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k I was adding as a table

Modified to a measure, but I get no results. 

parry2k
Super User
Super User

@mwjansen create a new table for body parts and use the following DAX. See attached file for reference:

 

Body Parts Count = 
VAR __Count = 
SUMX ( 
    'Table',
    VAR __CurrentRow =  SUBSTITUTE ( 'Table'[Row], "," , "|" )
    VAR __CurrentRowTotalBodyParts = PATHLENGTH ( __CurrentRow )
    VAR __CurrentBodyPartsTable = 
        SELECTCOLUMNS ( 
            ADDCOLUMNS ( 
                GENERATESERIES ( 1, __CurrentRowTotalBodyParts ), 
                "Current Part", PATHITEM ( __CurrentRow, [Value] ) 
            ), 
            "Current Part", [Current Part] 
        )
    VAR __BodyPartsFound =  
    FILTER ( 
        CROSSJOIN ( __CurrentBodyPartsTable, 'Body Parts' ),
        CONTAINSSTRING ( [Current Part], [Body Part] )
    )
    RETURN
       COUNTROWS ( __BodyPartsFound )
    
)
RETURN 
    __Count 



        

 

Result:

 

parry2k_0-1741730130576.png

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k I believe I made all the subs in the DAX. 

"The expression specified in the query is not a valid table expression"

Body Parts Count = 
VAR __Count = 
SUMX ( 
    'OR Incident Log',
    VAR __CurrentRow =  SUBSTITUTE ( 'OR Incident Log'[BODY PART], "," , "|" )
    VAR __CurrentRowTotalBodyParts = PATHLENGTH ( __CurrentRow )
    VAR __CurrentBodyPartsTable = 
        SELECTCOLUMNS ( 
            ADDCOLUMNS ( 
                GENERATESERIES ( 1, __CurrentRowTotalBodyParts ), 
                "Current Part", PATHITEM ( __CurrentRow, [Value] ) 
            ), 
            "Current Part", [Current Part] 
        )
    VAR __BodyPartsFound =  
    FILTER ( 
        CROSSJOIN ( __CurrentBodyPartsTable, 'Anatomy' ),
        CONTAINSSTRING ( [Current Part], [Body Part] )
    )
    RETURN
       COUNTROWS ( __BodyPartsFound )
    
)
RETURN 
    __Count 

 

"Current Part" is highlighted red 

parry2k
Super User
Super User

@mwjansen how many approx. rows you have in the transaction tables?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 645 rows. 

Also, I want to exclude the (r) and (l) identifiers in the cells. 

parry2k
Super User
Super User

@mwjansen you need to create a table with all the body parts that you want to count. once that table is available, you can iterate thru each row value of that table and check with transaction table to get the count.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 

I think I understand what you've written, but have no idea how to get started. 

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.