Power BI 从多个文本列中获取最小值
Power BI taking min value from Multiple text columns
我有这些数据
ID Daig 1 Daig 2 Daig 3 Daig 4
AA1 5 X X 2
AA2 X 1 4 X
AA3 7 3 X X
AA4 X X 2 6
AA5 X X X 3
我想从忽略文本的列中提取最小值 (X)
我写了下面的 DAX
Min Value = VAR V1 = IF(Data[Daig 1 ]="X",100,VALUE(Data[Daig 1 ]))
VAR V2 = IF(Data[Daig 2]="X",100,VALUE(Data[Daig 1 ]))
VAR V3 = IF(Data[Daig 3]="X",100,VALUE(Data[Daig 1 ]))
VAR V4 = IF(Data[Daig 4]="X",100,VALUE(Data[Daig 1 ]))
VAR temp = {V1, V2, V3, V4}
RETURN
MINX(Data,temp)
它给出了错误
预期输出
这是一个度量:
Min Value =
MIN (
MIN (
MIN (
VALUE ( SUBSTITUTE ( SELECTEDVALUE ( Data[Daig 1] ), "X", 999 ) ),
VALUE ( SUBSTITUTE ( SELECTEDVALUE ( Data[Daig 2] ), "X", 999 ) )
),
VALUE ( SUBSTITUTE ( SELECTEDVALUE ( Data[Daig 3] ), "X", 999 ) )
),
VALUE ( SUBSTITUTE ( SELECTEDVALUE ( Data[Daig 4] ), "X", 999 ) )
)
我将这种方法用作新的计算列:
Min_Value =
var __innerTab =
SELECTCOLUMNS(
GENERATE( VALUES(Data[ID])
, ROW(
"d1", IF(Data[Daig 1]="X",100,VALUE(Data[Daig 1])),
"d2", IF(Data[Daig 2]="X",100,VALUE(Data[Daig 2])),
"d3", IF(Data[Daig 3]="X",100,VALUE(Data[Daig 3])),
"d4", IF(Data[Daig 4]="X",100,VALUE(Data[Daig 4]))))
,
"min", min(min( Min([d1], [d2]),[d3]),[d4]))
return
__innerTab
我有这些数据
ID Daig 1 Daig 2 Daig 3 Daig 4
AA1 5 X X 2
AA2 X 1 4 X
AA3 7 3 X X
AA4 X X 2 6
AA5 X X X 3
我想从忽略文本的列中提取最小值 (X) 我写了下面的 DAX
Min Value = VAR V1 = IF(Data[Daig 1 ]="X",100,VALUE(Data[Daig 1 ]))
VAR V2 = IF(Data[Daig 2]="X",100,VALUE(Data[Daig 1 ]))
VAR V3 = IF(Data[Daig 3]="X",100,VALUE(Data[Daig 1 ]))
VAR V4 = IF(Data[Daig 4]="X",100,VALUE(Data[Daig 1 ]))
VAR temp = {V1, V2, V3, V4}
RETURN
MINX(Data,temp)
它给出了错误
预期输出
这是一个度量:
Min Value =
MIN (
MIN (
MIN (
VALUE ( SUBSTITUTE ( SELECTEDVALUE ( Data[Daig 1] ), "X", 999 ) ),
VALUE ( SUBSTITUTE ( SELECTEDVALUE ( Data[Daig 2] ), "X", 999 ) )
),
VALUE ( SUBSTITUTE ( SELECTEDVALUE ( Data[Daig 3] ), "X", 999 ) )
),
VALUE ( SUBSTITUTE ( SELECTEDVALUE ( Data[Daig 4] ), "X", 999 ) )
)
我将这种方法用作新的计算列:
Min_Value =
var __innerTab =
SELECTCOLUMNS(
GENERATE( VALUES(Data[ID])
, ROW(
"d1", IF(Data[Daig 1]="X",100,VALUE(Data[Daig 1])),
"d2", IF(Data[Daig 2]="X",100,VALUE(Data[Daig 2])),
"d3", IF(Data[Daig 3]="X",100,VALUE(Data[Daig 3])),
"d4", IF(Data[Daig 4]="X",100,VALUE(Data[Daig 4]))))
,
"min", min(min( Min([d1], [d2]),[d3]),[d4]))
return
__innerTab