在两个表中使用 OR 条件计算

编程入门 行业动态 更新时间:2024-10-25 16:20:52
本文介绍了在两个表中使用 OR 条件计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

为了对蓝色产品或属于鞋类的产品的销售额求和,我使用以下 DAX 表达式:

In order to Sum the sales amount of blue products OR products that belong to category shoes, I'm using the following DAX expression:

CALCULATE( SUM(Table[SalesAmount]), FILTER( Table, Table[Color] = "Blue" || Table[Category] = "Shoes") )

但是,这不适用于两个不同的表(颜色和类别),例如:

However, this doesn't work with two different tables (Colors and Categories), like:

CALCULATE( SUM(Table[SalesAmount]), FILTER( Table, Colors[Color] = "Blue" || Categories[Category] = "Shoes") )

谁能帮忙?

谢谢!

推荐答案

在网上搜索导致我找到 这个论坛主题.借用 OwenAuger 的帖子,我提出以下公式:

Searching the web led me to this forum topic. Borrowing from OwenAuger's post, I propose the following formula:

CALCULATE(SUM(Table[SalesAmount]), FILTER(SUMMARIZE(Table, Colors[Color], Categories[Category]), Colors[Color] = "Blue" || Categories[Category] = "Shoes"))

我们通过使用 SUMMARIZE 创建一个包含我们需要的所有部分的单个表来绕过单个表的限制.

We get around the single table restriction by using SUMMARIZE to create a single table that has all of the pieces we need.

更多推荐

在两个表中使用 OR 条件计算

本文发布于:2023-10-30 12:05:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1542796.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条件   两个

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!