如何检查列的值是否在数组列表中 – Azure数据工厂?

huangapple go评论65阅读模式
英文:

How to check if the value of the column is in array list- Azure data factory?

问题

我想检查在参数中的客户 ID。

这是我的示例数据。

客户 ID,客户名称,联系人,电话号码,电子邮件地址

1001,ABC 公司,约翰·史密斯,555-1234,john@abc.com

1002,XYZ 公司,简·多,555-5678,jane@xyz.com

1003,Acme 公司,鲍勃·约翰逊,555-2468,bob@acme.com

1004,史密斯和儿子,玛丽·史密斯,555-3698,mary@smith.com

1005,琼斯公司,汤姆·琼斯,555-7890,tom@jones.com

我有一个数组列表,它作为参数传递给数据流。我将其与上述数据一起添加为新列。添加后,我的数据如下所示。

客户 ID,客户名称,联系人,电话号码,电子邮件地址,客户利润数组

1001,ABC 公司,约翰·史密斯,555-1234,john@abc.com,[1001,1002,1007]

1002,XYZ 公司,简·多,555-5678,jane@xyz.com,[1001,1002,1007]

1003,Acme 公司,鲍勃·约翰逊,555-2468,bob@acme.com,[1001,1002,1007]

1004,史密斯和儿子,玛丽·史密斯,555-3698,mary@smith.com,[1001,1002,1007]

1005,琼斯公司,汤姆·琼斯,555-7890,tom@jones.com,[1001,1002,1007]

现在,我想在该数组中的客户 ID 可用时显示 。在上面的示例中,第一行和第二行应显示 ,其他行应显示值

我尝试为该列提供表达式,即 iif({Customer ID} in $Customer_profit_array, 'Yes','No')。但这不是一个有效的表达式。如何解决这个问题?

英文:

I wanted to check the customer Ids which are in the parameters.

This is my sample data.

Customer ID,Customer Name,Contact Person,Phone Number,Email Address

1001,ABC Inc.,John Smith,555-1234,john@abc.com

1002,XYZ Corp.,Jane Doe,555-5678,jane@xyz.com

1003,Acme Co.,Bob Johnson,555-2468,bob@acme.com

1004,Smith & Sons,Mary Smith,555-3698,mary@smith.com

1005,Jones Inc.,Tom Jones,555-7890,tom@jones.com

I have an array list and it is passed as a parameter to data flow. I added this as a new column along with the above data. After adding my data looks like this.

Customer ID,Customer Name,Contact Person,Phone Number,Email Address, Customer_profit_array

1001,ABC Inc.,John Smith,555-1234,john@abc.com,[1001,1002,1007]

1002,XYZ Corp.,Jane Doe,555-5678,jane@xyz.com,[1001,1002,1007]

1003,Acme Co.,Bob Johnson,555-2468,bob@acme.com,[1001,1002,1007]

1004,Smith & Sons,Mary Smith,555-3698,mary@smith.com,[1001,1002,1007]

1005,Jones Inc.,Tom Jones,555-7890,tom@jones.com,[1001,1002,1007]

Now, I want to display yes whenever customer id is available in that array. In the above example row1 and row2 should have yes and others should have value as no.

I tried giving expression for that column as iif({Customer ID} in $Customer_profit_array, 'Yes','No'). But this is not a valid expression. How to solve this?

答案1

得分: 0

To check if the data is in array, you can use contain function in dataflow.

Syntax:
contains(<value1> : array, <value2> : unaryfunction)

The result of contains function will be of Boolean type.

  • Give the expression for new column as, iif(contains({ Customer_profit_array},#item=={Customer ID}),'Yes','No').

This expression checks if customer id is in Customer_profit_array column.

Output

Customer ID Customer Name Contact Person Phone Number Email Address Customer_profit_array customer_available
1001 ABC Inc. John Smith 555-1234 john@abc.com [1001,1002,1007] Yes
1002 XYZ Corp. Jane Doe 555-5678 jane@xyz.com [1001,1002,1007] Yes
1003 Acme Co. Bob Johnson 555-2468 bob@acme.com [1001,1002,1007] No
1004 Smith & Sons Mary Smith 555-3698 mary@smith.com [1001,1002,1007] No
1005 Jones Inc. Tom Jones 555-7890 tom@jones.com [1001,1002,1007] No

Reference: https://learn.microsoft.com/en-us/azure/data-factory/data-flow-expressions-usage#contains

英文:

To check if the data is in array, you can use contain function in dataflow.

Syntax:
contains(<value1> : array, <value2> : unaryfunction)

The result of contains function will be of Boolean type.

  • Give the expression for new column as, iif(contains({ Customer_profit_array},#item=={Customer ID}),'Yes','No').

如何检查列的值是否在数组列表中 – Azure数据工厂?

This expression checks if customer id is in Customer_profit_array column.

Output

Customer ID Customer Name Contact Person Phone Number Email Address Customer_profit_array customer_available
1001 ABC Inc. John Smith 555-1234 john@abc.com [1001,1002,1007] Yes
1002 XYZ Corp. Jane Doe 555-5678 jane@xyz.com [1001,1002,1007] Yes
1003 Acme Co. Bob Johnson 555-2468 bob@acme.com [1001,1002,1007] No
1004 Smith & Sons Mary Smith 555-3698 mary@smith.com [1001,1002,1007] No
1005 Jones Inc. Tom Jones 555-7890 tom@jones.com [1001,1002,1007] No

Reference: https://learn.microsoft.com/en-us/azure/data-factory/data-flow-expressions-usage#contains

huangapple
  • 本文由 发表于 2023年5月10日 16:26:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76216354.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定