如何在第一列中使用给定的字符串匹配条件在power bi中创建新列,并从另一列获取值以创建新列?

问题描述 投票:0回答:1

我的表如下

Col1 Col2

11_A    9
12_B    8
13_C    7
14_A    6
15_A    4

查询后我们需要的表

Col1  Col2  Col3

11_A    0   9
12_B    8   0
13_C    7   0
14_A    0   6
15_A    0   4

我的查询是

Col3 = 
LEFT( 'Table'[Col2], 
     SEARCH("A", 'Table'[Col1], 0, 
         LEN('Table'[Col1])
     )
)
powerbi powerbi-desktop powerbi-embedded powerbi-datasource powerbi-custom-visuals
1个回答
1
投票
转到查询设计器Add Column > Custom Column并使用以下表达式:

enter image description here

enter image description here

更新

您需要两个表达式(两个新列):

一个是:

'Your Column3 =if Text.Contains([Col1], "A") = true then [Col2] else 0

和第二个:

'Your Column2 =if Text.Contains([Col1], "A") = false then [Col2] else 0

© www.soinside.com 2019 - 2024. All rights reserved.