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
PoweredOut
Resolver I
Resolver I

Conditional Column, check values from other rows in the same table

Hi Experts

 

I would like to create a condional column.

 

I want to compare three columns from the same table and check if the values are the same in other rows.

 

Conditions are if [ID] = [ID](OtherRows) and  [Stage] = [Stage](OtherRows) and [Status] <> [Status](OtherRows), "Declined", "Approved"

 

I basically want to check if the Status is anything but approved based on the condions, it should be declined.

 

I hope this make sense

 

Thanks in advance

IDStageStatusWanted Condional Column
1OpenDeclinedDeclined
1OpenApprovedDeclined
1OpenDeclinedDeclined
1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @PoweredOut ,

 

You can group on [ID] and keep all other rows using the All Rows aggregator. Then just evaluate the nested table for the "Declined" keyword.

If you want to add more matching dimensions e.g. [Stage] etc., then just include thes with [ID] before you group.

 

Working example query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfIvSM0DUi6pyTmZeakpSrE6KOKOBQVF+WWY4gj1sQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Stage = _t, Status = _t]),
    groupID = Table.Group(Source, {"ID"}, {{"data", each _, type table [ID=nullable text, Stage=nullable text, Status=nullable text, Wanted Condional Column=nullable text]}}),
    addStatusSummary = Table.AddColumn(groupID, "statusSummary", each if List.Contains([data][Status], "Declined") then "Declined" else "Approved"),
    expandDataCols = Table.ExpandTableColumn(addStatusSummary, "data", {"Stage", "Status"}, {"Stage", "Status"})
in
    expandDataCols

 

 

Example output:

BA_Pete_0-1675176244995.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @PoweredOut ,

 

You can group on [ID] and keep all other rows using the All Rows aggregator. Then just evaluate the nested table for the "Declined" keyword.

If you want to add more matching dimensions e.g. [Stage] etc., then just include thes with [ID] before you group.

 

Working example query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfIvSM0DUi6pyTmZeakpSrE6KOKOBQVF+WWY4gj1sQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Stage = _t, Status = _t]),
    groupID = Table.Group(Source, {"ID"}, {{"data", each _, type table [ID=nullable text, Stage=nullable text, Status=nullable text, Wanted Condional Column=nullable text]}}),
    addStatusSummary = Table.AddColumn(groupID, "statusSummary", each if List.Contains([data][Status], "Declined") then "Declined" else "Approved"),
    expandDataCols = Table.ExpandTableColumn(addStatusSummary, "data", {"Stage", "Status"}, {"Stage", "Status"})
in
    expandDataCols

 

 

Example output:

BA_Pete_0-1675176244995.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thanks Pete

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.