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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ARRAM
New Member

Adding New Column If Column B Reach The Target

Hello,

Well I have this table for an example,

f4d87325037a45e4d4382ccbc9225505

 

and I want to add new column name (Status) that's show if column B have more or equal 100 then Status = "Complete" else "Not Complete".

80bad7891ddec11e7de3a751ba9be9c1

 

And then I change the status "Not Complete" to "Complete" IF any duplicate in name column have 1 Complete value in status column.

bfa2bf5cd7476ace42d1aa635e8ac2d1

 

So could anyone help me how to make this in power query and i'd really appreciate it.

2 ACCEPTED SOLUTIONS
ImkeF
Community Champion
Community Champion

Hi @ARRAM ,
I would recommend to group your data by Country and then use MAX-aggregation and the All Rows aggregation.
That allows you to add a custom column with a simple formula like if [myNewMaxColumn] > 100 then "Complete" else "Not complete". After that, expand the remaining columns from the "All Rows" table.

Next time, please provide your sample data in a form that can be copied and worked with like described here:
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...


Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

jennratten
Super User
Super User

Hello - this is how you can achieve the expected result... I have included the script and screenshots below as well as a sample file.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZNtb4IwEMe/CuG1S7YsfoBRh52SjADTLMYXVS7SUFpTcInffr2WuhLdK+4pd7/799jt4s17PIs30A+9+c7j/WwXl9SYZaO0jb082+A2MXaihkFAHzFZR4SdwOVdQUL+K5i7gnxtnIrrMV1dDjb96rLlJw5Vx9ZyuFjxhi15C1HBXOJ1HEYy4xABTIL+A09xlxRk7YIjeVn5LuVgBofM9Ns49FprNnAlo3yc4onLlXFWphlcA9K0wD3URXN5ilLNOgiRF8ZegGZcCLjokLmwCmrWQiA1EpesrgUExFX1UClPXX08TnudESGHmokQ+p5rLKeIRU0jAQc2AU4fAJMShddMtj2E50HwZkjDuJzcxDqQCp8g5Ez8RakuMlOOrWs4Ai/xhZdC/YTq5ngQOZOSw4Q0w+PJ/PG40i8svXTnADJDXTN+aoaJnEsrp4/6t7d0/PB0+xFGsGJr7G0DIAKwdBK8CYjrp0oHWBT1o8DqqXw0s2HRwQSN4L6EnUOw7P4o978=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Category Code" = _t, #"Product Category Name" = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Category Code", type text}, {"Product Category Name", type text}, {"Sales", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Product Category Name"}, {{"SumSales", each List.Sum([Sales]), type nullable number}, {"Data", each _, type table [Category Code=nullable text, Product Category Name=nullable text, Sales=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Status", each if [SumSales] >= 100 then "Complete" else "Not Complete", type text),
    #"Expanded Data" = Table.ExpandTableColumn(#"Added Custom", "Data", {"Sales"}, {"Sales"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Data",{"SumSales"})
in
    #"Removed Columns"

jennratten_0-1666459872488.png

 

View solution in original post

2 REPLIES 2
jennratten
Super User
Super User

Hello - this is how you can achieve the expected result... I have included the script and screenshots below as well as a sample file.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZNtb4IwEMe/CuG1S7YsfoBRh52SjADTLMYXVS7SUFpTcInffr2WuhLdK+4pd7/799jt4s17PIs30A+9+c7j/WwXl9SYZaO0jb082+A2MXaihkFAHzFZR4SdwOVdQUL+K5i7gnxtnIrrMV1dDjb96rLlJw5Vx9ZyuFjxhi15C1HBXOJ1HEYy4xABTIL+A09xlxRk7YIjeVn5LuVgBofM9Ns49FprNnAlo3yc4onLlXFWphlcA9K0wD3URXN5ilLNOgiRF8ZegGZcCLjokLmwCmrWQiA1EpesrgUExFX1UClPXX08TnudESGHmokQ+p5rLKeIRU0jAQc2AU4fAJMShddMtj2E50HwZkjDuJzcxDqQCp8g5Ez8RakuMlOOrWs4Ai/xhZdC/YTq5ngQOZOSw4Q0w+PJ/PG40i8svXTnADJDXTN+aoaJnEsrp4/6t7d0/PB0+xFGsGJr7G0DIAKwdBK8CYjrp0oHWBT1o8DqqXw0s2HRwQSN4L6EnUOw7P4o978=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Category Code" = _t, #"Product Category Name" = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Category Code", type text}, {"Product Category Name", type text}, {"Sales", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Product Category Name"}, {{"SumSales", each List.Sum([Sales]), type nullable number}, {"Data", each _, type table [Category Code=nullable text, Product Category Name=nullable text, Sales=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Status", each if [SumSales] >= 100 then "Complete" else "Not Complete", type text),
    #"Expanded Data" = Table.ExpandTableColumn(#"Added Custom", "Data", {"Sales"}, {"Sales"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Data",{"SumSales"})
in
    #"Removed Columns"

jennratten_0-1666459872488.png

 

ImkeF
Community Champion
Community Champion

Hi @ARRAM ,
I would recommend to group your data by Country and then use MAX-aggregation and the All Rows aggregation.
That allows you to add a custom column with a simple formula like if [myNewMaxColumn] > 100 then "Complete" else "Not complete". After that, expand the remaining columns from the "All Rows" table.

Next time, please provide your sample data in a form that can be copied and worked with like described here:
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...


Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.