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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Group column then comma-separate the rest

I have the following dataset:

https://i.ibb.co/3h3mzrN/Capture.png

 

I just want to group rows that have the same ComputerID, then comma-separate the other columns (But without duplicates in the comma-separated lists (a.k.a. "distinct" values)):

 

ComputerIDGroupedKBID
224603003
674538461
3594535105, 982861, 4536953, 4520002

 

I tried following this step-by-step picture tutorial on Stackoverflow:

https://stackoverflow.com/questions/64262999/need-a-comma-separated-group-by-in-powerbi

 

...but the data errors out (Removing Errors deletes all the rows):

https://i.ibb.co/ykxFgp3/Capture2.png

 

Full Power Query:

 

let
Source = MySQL.Database("MyServer", "MyDatabase", [ReturnSingleDatabase=true, Query="Select UUID() AS id, cl.name as Client, c.ComputerID, d.Name, c.OS, c.Title, c.KBID,
SuccessCount, NotAttemptedCount, FailedCount, Compliance, Last_Updated, c.Hotfixid, h.date_added, DATEDIFF(CURDATE(),h.date_added) as Age,
e.Approved, h.severity, d.UpTime, f.spare, f.`AD Computer Last Logon`, IF(d.lastcontact > (NOW() - INTERVAL 15 MINUTE), 1, 0) AS 'Online'
From hotfixcompliancedata c
JOIN computers d on d.ComputerID= c.ComputerID
JOIN clients cl on cl.clientid= d.clientid
JOIN hotfixdata h on h.hotfixid= c.hotfixid
JOIN hotfix e on e.hotfixid= c.hotfixid
JOIN v_extradatacomputers f on f.computerid= c.computerid
WHERE DATEDIFF(CURDATE(),h.date_added)>30 and compliance<100 and e.approved=2
GROUP BY c.KBID"]),
#"Removed Columns" = Table.RemoveColumns(Source,{"id", "Client", "Name", "OS", "Title", "SuccessCount", "NotAttemptedCount", "FailedCount", "Compliance", "Last_Updated", "Hotfixid", "date_added", "Age", "Approved", "severity", "UpTime", "spare", "AD Computer Last Logon", "Online"}),
#"Grouped Rows" = Table.Group(#"Removed Columns", {"ComputerID"}, {{"GroupedKBID", each _, type table [ComputerID=number, KBID=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each [GroupedKBID][Value])
in
#"Added Custom"

 

 

I also struggled to manually incorporate the Power Query answers here into my own dataset:

https://community.powerbi.com/t5/Desktop/group-by-a-column-and-the-group-item-to-be-shown-in-comma/m...

https://community.powerbi.com/t5/Desktop/Help-with-a-table-visualization/td-p/24143/page/2

 

Could someone help me group rows by a column, then comma-separate (distinctly) the rest of the columns?

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

[Value] is not one of your columns, so [GroupedKBID][Value] doesn't make sense. Try [GroupedKBID][KBID] instead.

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

[Value] is not one of your columns, so [GroupedKBID][Value] doesn't make sense. Try [GroupedKBID][KBID] instead.

Anonymous
Not applicable

Oh thanks! The StackOverflow example had a column name called "Value", but that's also a generic PowerBI variable name ( https://i.ibb.co/6gw8BZC/Capture.png ), thus the StackOverflow answer misled me a bit. I appreciate the nudge in the right direction

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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