Forum Discussion
dlhtox74
Nov 19, 2021Copper Contributor
Return values from some cells if other cells meet criteria
I am trying to return a list of computer names and possibly Windows build version and memory available if build version is less than X and memory is less than X. So ideally on Sheet 1 (Overv...
SergeiBaklan
Nov 19, 2021Diamond Contributor
With some assumptions (builds are numbers, etc) you may use Power Query
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Removed Other Columns" = Table.SelectColumns(
Source,
{"Device Name", "Build", "Memory"}),
#"Changed Type" = Table.TransformColumnTypes(
#"Removed Other Columns",
{
{"Device Name", type text},
{"Build", Int64.Type},
{"Memory", Int64.Type}
}),
#"Added Custom" = Table.AddColumn(
#"Changed Type",
"Action",
each
if [Build] < 19042
then
if [Memory] < 15000
then "Replace"
else "Reimage"
else "Nothing to do")
in
#"Added Custom"
Results is
- dlhtox74Nov 19, 2021Copper Contributor
So I want to display data ONLY if the Memory and Build #'s meet the criteria.
So I don't want any "Nothing to do" columns, I only want "Replace" or "Reimage".
- SergeiBaklanNov 19, 2021Diamond Contributor
That's simple filter in Power Query transformation
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Removed Other Columns" = Table.SelectColumns( Source, {"Device Name", "Build", "Memory"}), #"Changed Type" = Table.TransformColumnTypes( #"Removed Other Columns", { {"Device Name", type text}, {"Build", Int64.Type}, {"Memory", Int64.Type} }), #"Added Custom" = Table.AddColumn( #"Changed Type", "Action", each if [Build] < 19042 then if [Memory] < 15000 then "Replace" else "Reimage" else "Nothing to do"), #"Filtered Rows" = Table.SelectRows( #"Added Custom", each ([Action] <> "Nothing to do")) in #"Filtered Rows"
it gives