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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Conditional statement open/deleted

Hi,

I'm pretty new to Power Query and I need help to implement a new column that shows if a specific OppID is open or deleted if the dataload is different from the refresh time.
Right now I have implemented this step as you can see below:

Capture.PNG

However, if the specific "OppID" is Open then the column should return "Open" for all rows that that specific OppID. Like this:
Capture1.PNG

2 ACCEPTED SOLUTIONS
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You can use Group By on OppID, as below.

image.png

 

Add Custom Column with code as below.

image.png

And later expan back your table

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski


columns.

View solution in original post

AnkitBI
Solution Sage
Solution Sage

You can use below in Power Query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hc2xDcAwCATAXaiNBP9JwSyW918jREm6YCQa/gQ/p7gMMdccmMe9QN2eZY3X0TgbPxo/a0dGNLXYeB5/0b+jdmaEqP+z6WfTz13/ugA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [OppId = _t, DataLoad = _t, LastRefresh = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"OppId", Int64.Type}, {"DataLoad", type date}, {"LastRefresh", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"OppId"}, {{"AllRows", each _, type table [OppId=number, DataLoad=date, LastRefresh=date]}}),
    Custom1 = Table.AddColumn(#"Grouped Rows","Status",each if(Table.RowCount(Table.SelectRows([AllRows],each [DataLoad] = [LastRefresh])) > 0) then "Open" else "deleted"),
    #"Expanded AllRows" = Table.ExpandTableColumn(Custom1, "AllRows", {"DataLoad", "LastRefresh"}, {"DataLoad", "LastRefresh"})
in
    #"Expanded AllRows"

In DAX, you can add Conditional Column as below

 

Status =
IF (
    COUNTROWS (
        FILTER (
            'Table3',
            Table3[DataLoad] = EARLIER ( Table3[LastRefresh] )
                && Table3[OppId] = EARLIER ( Table3[OppId] )
        )
    ) > 0,
    "Open",
    "Deleted"
)

Thanks
Ankit Jain
Do Mark it as solution if the response resolved your problem. Do Kudo the response if it seems good and helpful.

View solution in original post

2 REPLIES 2
AnkitBI
Solution Sage
Solution Sage

You can use below in Power Query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hc2xDcAwCATAXaiNBP9JwSyW918jREm6YCQa/gQ/p7gMMdccmMe9QN2eZY3X0TgbPxo/a0dGNLXYeB5/0b+jdmaEqP+z6WfTz13/ugA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [OppId = _t, DataLoad = _t, LastRefresh = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"OppId", Int64.Type}, {"DataLoad", type date}, {"LastRefresh", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"OppId"}, {{"AllRows", each _, type table [OppId=number, DataLoad=date, LastRefresh=date]}}),
    Custom1 = Table.AddColumn(#"Grouped Rows","Status",each if(Table.RowCount(Table.SelectRows([AllRows],each [DataLoad] = [LastRefresh])) > 0) then "Open" else "deleted"),
    #"Expanded AllRows" = Table.ExpandTableColumn(Custom1, "AllRows", {"DataLoad", "LastRefresh"}, {"DataLoad", "LastRefresh"})
in
    #"Expanded AllRows"

In DAX, you can add Conditional Column as below

 

Status =
IF (
    COUNTROWS (
        FILTER (
            'Table3',
            Table3[DataLoad] = EARLIER ( Table3[LastRefresh] )
                && Table3[OppId] = EARLIER ( Table3[OppId] )
        )
    ) > 0,
    "Open",
    "Deleted"
)

Thanks
Ankit Jain
Do Mark it as solution if the response resolved your problem. Do Kudo the response if it seems good and helpful.

Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You can use Group By on OppID, as below.

image.png

 

Add Custom Column with code as below.

image.png

And later expan back your table

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski


columns.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.