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
betulurh
Regular Visitor

Create new columns by using a specific column based on criterias

Hello everyone, 

I am new in PowerBI and I have a question that I could not find the proper soluotion: 

 

I have table like this: 

RoleRiskOperation
AccountantA028;0113Create
AccountantA028;0113Edit
AccountantA028;0113Delete
AccountantC028;011AAdd
AccountantC028;011ADivide

 

I want to create new columns by using operation column based on role and risk column like this:

RoleRisk IdentitiesOperation 1Operation 2Operation 3
AccountantA028;0113CreateEditDelete
AccountantC028;011AAddDivide-

 

I would be really appreciate if you could help. Thanks in advance. 

4 REPLIES 4
Ahmedx
Super User
Super User

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Thank you for your reply and help! However, since I am new in PowerBI this answer was too complex to implement for me. That's why I did not mark the "Accept as Solution" button. Thanks again.

Ahmedx
Super User
Super User

see 2 variant

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxOzi/NK0nMK1HSUXI0MLKwNjA0NAaynYtSE0tSlWJ18KhxTckswa/CJTUnFZspzlA1jiD1KSn4FbhklmWmAA2JBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Role = _t, Risk = _t, Operation = _t]),
    from = Table.TransformColumnTypes(Source,{{"Role", type text}, {"Risk", type text}, {"Operation", type text}}),
    from2 = Table.Group(from, {"Role", "Risk"}, {{"Count", (x)=> x[Operation]}}),
    f = (go)=>
Table.FromList (
   {go},
    ( x ) => x,
   List.Transform ( { 1 .. List.Count ( {go}{0} )  }, ( y ) => "Operation-" & Text.From ( y ) )
  ),
    Custom1 = Table.TransformColumns( from2,{"Count",f}),
    #"Expanded Count" = Table.ExpandTableColumn(Custom1, "Count", {"Operation-1", "Operation-2", "Operation-3"}, {"Operation-1", "Operation-2", "Operation-3"})
in
    #"Expanded Count"


https://1drv.ms/u/s!AiUZ0Ws7G26Rh0-lKldJxpmRvQ3X?e=ycpoG5

Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
https://1drv.ms/u/s!AiUZ0Ws7G26Rh05bb-MGZXagSih5?e=LCRCma

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxOzi/NK0nMK1HSUXI0MLKwNjA0NAaynYtSE0tSlWJ18KhxTckswa/CJTUnFZspzlA1jiD1KSn4FbhklmWmAA2JBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Role = _t, Risk = _t, Operation = _t]),
    from = Table.TransformColumnTypes(Source,{{"Role", type text}, {"Risk", type text}, {"Operation", type text}}),
    fx =(y)=>
[
   t =  Table.Transpose( Table.FromColumns({y})),
   N= Table.ColumnNames(t),
   L = List.ReplaceValue(N, "Column", "Operation", Replacer.ReplaceText),
   Results = Table.RenameColumns( t,List.Zip( { N,L} ),MissingField.Ignore )][Results],

    Custom1 = from,
    from2 = Table.Group(Custom1, {"Role", "Risk"}, {{"Count",(x)=> x[Operation]}}),
    Custom2 = Table.TransformColumns(from2,{"Count",fx}),
    #"Expanded Count" = Table.ExpandTableColumn(Custom2, "Count", {"Operation1", "Operation2", "Operation3"}, {"Operation1", "Operation2", "Operation3"})
in
   #"Expanded Count"

Screen Capture #949.png

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.