Forum Discussion
Table.SelectRows in conjunction with if statement from another table
- 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
Hi Jennratten,
Unfortunatley both of those give me "We cannot convert the value null to type Table."
= Table.SelectRows(#"Sorted Rows", each if Table.IsEmpty(CSR)
then Table.SelectRows(#"Sorted Rows", [REP] = REP)
else Table.SelectRows(#"Sorted Rows", [CSR] = CSR))
adding a screenshot of the CSR table drilldown incase I've gone wrong there but as before it works fine when using 1 criteria:
let
Source = Excel.CurrentWorkbook(){[Name="CSR"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CSR", type text}}),
#"Uppercased Text" = Table.TransformColumns(#"Changed Type",{{"CSR", Text.Upper, type text}}),
CSR = #"Uppercased Text"{0}[CSR]
in
CSR
It looks like REP is a value of type text. Is CSR also a text value when it is populated?
- Anonymous4 years agoNot applicable
Yea both Tables/Lists are set as type Text and the columns are also type Text