Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
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?
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.
@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.
@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:
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
@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.
@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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
85 | |
78 | |
53 | |
38 | |
36 |
User | Count |
---|---|
100 | |
85 | |
47 | |
45 | |
44 |