Forum Discussion
Need help excluding certain rows based on value in another column
- 5 years ago
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIB4rzSnBwgZWSgFKsTrWQEFTVECBkDmY6oQiZoeg3BoqZApj8QmyCEzNAUmoBFzYFMZyRRC6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [OfferID = _t, Status = _t, OriginalOfferID = _t, ClientID = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"OfferID", Int64.Type}, {"Status", type text}, {"OriginalOfferID", Int64.Type}, {"ClientID", Int64.Type}}), #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([OriginalOfferID] = null) and ([Status] = "D")), #"Filtered Rows2" = Table.SelectRows(#"Filtered Rows", each Table.RowCount(Table.SelectRows(#"Changed Type", (inner)=> inner[Status]<>[Status] and inner[OriginalOfferID]=[OfferID]))=0) in #"Filtered Rows2"Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
- 5 years ago
I have no idea what you are doing. Works fine on my end. See attached
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Getting closer but the code above still doesn't give me the result i need.
Client ID is not a relevant factor here, the table cloud have looked just like this:
| OfferID | Status | OriginalOfferID | ClientID |
| 1 | D | null | 20 |
| 2 | D | 1 | 20 |
| 3 | A | 1 | 20 |
| 4 | D | null | 20 |
| 5 | O | 4 | 20 |
| 6 | D | null | 20 |
| 7 | C | null | 20 |
The result however is still the same. If these were all the records in the database the total number of actual 'Denied" offers would be 1, i.e. order 6.
I need all offers with status "D" where OriginalOfferID = null provided that the 'ID' of these records doesn't show anywhere in te column "OriginalOfferID" for offers with a status other than "D". If it does that offer should be excluded.