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
Anonymous
Not applicable

Column to rows/ Group by

Hello, 

I have a Table with the following data:

Company IdSales PersonProduct 
999AlexA
999AlexB
999AlexC
1000BrainA
1000BrainB
1005MaxA

 

 

Expected Output:

Company IdSales PersonABC
999AlexTRUETRUETRUE
1000BrainTRUETRUEFALSE
1005MaxTRUEFALSEFALSE

 

How to group them to see which salesperson has sold all three products? To identify I marked them as "TRUE" OR "FALSE"  is their way to replace them with Icons ( ✔️ or ).

 

Thanks in advance !!!!

1 ACCEPTED SOLUTION
nandukrishnavs
Community Champion
Community Champion

@Anonymous 

 

Try the below PowerQuery

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WsrS0VNJRcsxJrQBRSrE6aEJOmELOYCFDAwMDkHxRYmYeXCuaoBNM0BTI8U2EWhELAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Company Id" = _t, #"Sales Person" = _t, #"Product " = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Company Id", Int64.Type}, {"Sales Person", type text}, {"Product ", type text}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Company Id", "Company Id - Copy"),
    #"Pivoted Column" = Table.Pivot(#"Duplicated Column", List.Distinct(#"Duplicated Column"[#"Product "]), "Product ", "Company Id - Copy")
in
    #"Pivoted Column"

 

Capture.JPG

 

initial.JPG

 

Capture.JPG

 

You can apply conditional formatting in the formatting pane.

fo.JPG

 

Capture.JPG



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 

 


Regards,
Nandu Krishna

View solution in original post

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

If you want to do it with DAX instead of M, you can use this approach.  

 

ProductSold = var salescount = COUNTROWS(Sales)+0
return if(salescount=0, "", "✔") // this uses Windows 10 emojis you can find with Windows Key and "."
 
This will get you the visual on the left.
saleschecks.png
If you want the one on the right, you need to do a little more.  Make a simple DAX calculated table with 
SalesProducts = VALUES(Sales[Product ])
and use that as your column in the matrix visual and then use this measure
 
ProductSold2 = var salescount = CALCULATE(COUNTROWS(Sales)+0, TREATAS(VALUES(SalesProducts[Product ]), Sales[Product ]))
return if(salescount=0, "", "✔") // note - the red X isn't default so you need to copy paste that text from https://getemoji.com/#symbols
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


nandukrishnavs
Community Champion
Community Champion

@Anonymous 

 

Try the below PowerQuery

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WsrS0VNJRcsxJrQBRSrE6aEJOmELOYCFDAwMDkHxRYmYeXCuaoBNM0BTI8U2EWhELAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Company Id" = _t, #"Sales Person" = _t, #"Product " = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Company Id", Int64.Type}, {"Sales Person", type text}, {"Product ", type text}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Company Id", "Company Id - Copy"),
    #"Pivoted Column" = Table.Pivot(#"Duplicated Column", List.Distinct(#"Duplicated Column"[#"Product "]), "Product ", "Company Id - Copy")
in
    #"Pivoted Column"

 

Capture.JPG

 

initial.JPG

 

Capture.JPG

 

You can apply conditional formatting in the formatting pane.

fo.JPG

 

Capture.JPG



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 

 


Regards,
Nandu Krishna

Anonymous
Not applicable

How can we group the data using DAX formula? Also, I'm pretty new to PowerQuery can you elaborate little on applied steps.

Thank You.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

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.