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
HenryJS
Post Prodigy
Post Prodigy

IF statement

Hi all,

 

How can I produce a column that says Live or Terminated with the below parameters:

 

  • Terminated: if any row with the same first part of the Friendly Placement Ref has a row where it is terminated then all terminated
  • Live: if any row with the same first part of te Friendly Placement does not have a termination

 

 

 Placements.PNG

 

2 REPLIES 2
amitchandak
Super User
Super User

You can get a count of termination like

Has Termination = countx(filter(Table,table[PlacementRef] =earlier(table[PlacementRef]) && table[Placement Type] ="Termination"),table[PlacementRef])

 

The same way other calculations can be done.

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi,

follow these Power Query steps:

// Table
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0MjbTNdQ1VNJRCshJTE7NTc0rUYrVAcoYGRpYYpcxMTY2xSpjZGpuboFXxggoE5JalJuZl1iSmZ8HlbOwMMZuk7mZEXY3GJmZm+CXAdnkWlGSmlcMt8fMxNQQuz1IoYDiulgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [FriendlyPlacementRef = _t, PlacementType = _t]),
    #"Duplicated Column" = Table.DuplicateColumn(Source, "FriendlyPlacementRef", "FriendlyPlacementRef - Copy"),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Duplicated Column", {{"FriendlyPlacementRef - Copy", each Text.BeforeDelimiter(_, "-"), type text}}),
    #"Added Custom" = Table.AddColumn(#"Extracted Text Before Delimiter", "Is Terminated", each if [PlacementType] = "Termination" then 1 else 0),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"FriendlyPlacementRef - Copy"}, {{"Group", each _, type table [FriendlyPlacementRef=text, PlacementType=text, #"FriendlyPlacementRef - Copy"=text, Is Terminated=number]}}),
    #"Add Status" = Table.AddColumn(#"Grouped Rows", "Add Status", each Table.AddColumn([Group], "New", (r) => if List.Sum([Group][Is Terminated]) > 0 then "Termination" else "Live")),
    #"Removed Other Columns" = Table.SelectColumns(#"Add Status",{"Add Status"}),
    #"Expanded Add Status" = Table.ExpandTableColumn(#"Removed Other Columns", "Add Status", {"FriendlyPlacementRef", "PlacementType", "New"}, {"FriendlyPlacementRef", "PlacementType", "New"})
in
    #"Expanded Add Status"

 

10-03-_2020_16-28-30.pngFigure: Start

 

10-03-_2020_16-29-44.png

Figure: Result

 

Regards FrankAT

 

 

 

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.