DAX表达式用于Power BI度量。

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

DAX expression for Power BI measure

问题

我正在尝试在POWER BI中创建一个度量,用于计算一段时间内的总收入,但它有很多条件。即

在以下条件下的总收入
Shipping type = "Incoming"(运输类型 = "入站")

Status = Invoiced, Shipped, Received(状态 = 已开票,已发货,已收到)

如果site = 29104,则排除产品 = S-ExtFreight,S-ProductInDelivery,S-WeighOnly

如果site = 33103,则排除产品 = S-ExtFreight,S-WeighOnly

如果site = 23103,则排除产品 = S-ExtFreight,SAxleWeigh

我尝试使用下面的表达式,但在将其绘制到图表上时没有返回任何值。

度量 2 = CALCULATE(
sum('事实表'[Amount]),
'事实表'[Site Code] = 29104 && '事实表'[Item Number] in {"S-ExtFreight","S-ProductInDelivery","S-WeighOnly"},
'事实表'[Site Code] = 33103 && '事实表'[Item Number] in {"S-ExtFreight","S-WeighOnly"},
'事实表'[Site Code] = 23103 && '事实表'[Item Number] in {"S-ExtFreight","S-AxleWeigh"})

感谢Ashok的更新。一旦我导入它,我就会遇到这个可视化错误。

英文:

DAX表达式用于Power BI度量。I am trying to create a measure in POWER BI, its to calculate the total revenue for a time period but it has a lot of conditions to it. i.e.

Total Revenue with following conditions
Shipping type = "Incoming"

Status = Invoiced,Shipped,Received

if site = 29104 exclude product = S-ExtFreight,S-ProductInDelivery,S-WeighOnly

if site = 33103 exclude product = S-ExtFreight,S-WeighOnly

if site = 23103 exclude product = S-ExtFreight,SAxleWeigh

I tried to use the below expression but its not throwing me any values when I plot it on a graph.

Measure 2 = CALCULATE(
sum('Fact table'[Amount]),
'Fact table'[Site Code] = 29104 & 'Fact table'[Item Number] in {"S-ExtFreight","S-ProductInDelivery","S-WeighOnly"},
'Fact table'[Site Code] = 33103 & 'Fact table'[Item Number] in {"S-ExtFreight","S-WeighOnly"},
'Fact table'[Site Code] = 23103 & 'Fact table'[Item Number] in {"S-ExtFreight","S-AxleWeigh"})

Thanks Ashok for the update. I get this visual error once I bring it in.

答案1

得分: 2

你需要使用 NOT([列名]) in 来排除产品。此外,您需要使用 && 表示与条件。

Measure 2 = CALCULATE( sum('事实表'[金额]), '事实表'[站点代码] = 29104 && NOT('事实表'[产品编号]) in {"S-ExtFreight","S-ProductInDelivery","S-WeighOnly"}, '事实表'[站点代码] = 33103 && NOT('事实表'[产品编号]) in {"S-ExtFreight","S-WeighOnly"}, '事实表'[站点代码] = 23103 && NOT('事实表'[产品编号]) in {"S-ExtFreight","S-AxleWeigh"})
英文:

You have to use NOT([Column Name]) in to exclude products. Also you need to use && for AND condition.

Measure 2 = CALCULATE( sum('Fact table'[Amount]), 'Fact table'[Site Code] = 29104 && NOT('Fact table'[Item Number])  in {"S-ExtFreight","S-ProductInDelivery","S-WeighOnly"}, 'Fact table'[Site Code] = 33103 && NOT('Fact table'[Item Number]) in {"S-ExtFreight","S-WeighOnly"}, 'Fact table'[Site Code] = 23103 && NOT('Fact table'[Item Number]) in {"S-ExtFreight","S-AxleWeigh"})

huangapple
  • 本文由 发表于 2023年6月9日 09:52:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76436711.html
匿名

发表评论

匿名网友

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

确定