Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I want to create a new column from Power query that if any other columns contain value "异常"then return value in new column "异常" else "正常". I have used List.ComtainsAny but have error.
Solved! Go to Solution.
Hi @henryzf
You only need to make a small modification to @dufoq3 's solution like below
= Table.AddColumn(#"Previous Step", "Custom", each if List.Contains(Record.ToList(_), "异常", (x,y)=> Text.Contains(Text.From(x),y)) then "异常" else "正常", type text)
In addition, here is another approach which is close to your original idea. You should use List.Contains function instead.
if List.Contains({[Device 1],[Device 2],[Device 3],[Device 4]}, "异常") then "异常" else "正常"
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
Hi @henryzf,,
Result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkxKfrqn6emOHSmpSjpKiYlJSrE6YFEIPyk5KQUmogBRqABVmZgIkQDKAPkpEEmIGIQNFIUyYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
Ad_Custom = Table.AddColumn(Source, "Custom", each if List.Contains(Record.ToList(_), "异常", (x,y)=> Text.Contains(x,y)) then "异常" else "正常", type text)
in
Ad_Custom
Hi dufoq3, I still get error. see below. the 159 is from column ID.
Expression.Error: We cannot convert the value 159 to type Text.
Details:
Value=159
Type=[Type]
Hi @henryzf
You only need to make a small modification to @dufoq3 's solution like below
= Table.AddColumn(#"Previous Step", "Custom", each if List.Contains(Record.ToList(_), "异常", (x,y)=> Text.Contains(Text.From(x),y)) then "异常" else "正常", type text)
In addition, here is another approach which is close to your original idea. You should use List.Contains function instead.
if List.Contains({[Device 1],[Device 2],[Device 3],[Device 4]}, "异常") then "异常" else "正常"
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
finally I go with your List.Contains. it is worked. My original way is use List.ComtainsAny but it failed. Thanks so much for your help.
I don't see the full code and I don't see an error. Impossible to help here...
Check out the July 2025 Power BI update to learn about new features.