Forum Discussion
Anonymous
4 years agoNot applicable
Table.SelectRows in conjunction with if statement from another table
Hi, Trying to utilise an if statement within a Table.SelectRows and not having any joy, had a good look around and can't quite find the right thing.... So table Inventory(90+) lists all inve...
- 4 years ago
Assuming that your REP and CSR are values and not tables, and you want to use one conditional statement, you would do it like this...
= Table.SelectRows(#"Sorted Rows", each if CSR = null then [REP] = REP else [CSR] = CSR )Example:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUUpRitWJVkoCslLhrDQwKxnISgezUuCsVCArQyk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CSR = _t, REP = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"CSR", type text}, {"REP", type text}}), CSR = null, //"b", REP = "h", SelectRows = Table.SelectRows(#"Changed Type" , each if CSR = null then [REP] = REP else [CSR] = CSR ) in SelectRows
jennratten
Super User
4 years agoAssuming that your REP and CSR are values and not tables, and you want to use one conditional statement, you would do it like this...
= Table.SelectRows(#"Sorted Rows", each if CSR = null
then [REP] = REP else [CSR] = CSR )
Example:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUUpRitWJVkoCslLhrDQwKxnISgezUuCsVCArQyk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CSR = _t, REP = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CSR", type text}, {"REP", type text}}),
CSR = null, //"b",
REP = "h",
SelectRows = Table.SelectRows(#"Changed Type" , each if CSR = null then [REP] = REP else [CSR] = CSR )
in
SelectRowsAnonymous
4 years agoNot applicable
Thank you this worked pefectly! Makes sense to write it like that now I see it 🙂