基于另一列的条件计算 [英] Conditional calculation based on another column

查看:110
本文介绍了基于另一列的条件计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个交叉引用表,另一个具有项目列表的表

I have a cross reference table and another table with the list of "Items"

我将 PKG连接到项目,因为 PKG具有不同的值。

I connect "PKG" to "Item" as "PKG" has distinct values.

 Example:

 **Cross table**              **Item table**
  Bulk   PKG                    Item  Value
  A        D                      A     2     
  A        E                      B     1     
  B        F                      C     4    
  C        G                      D     5   
                                  E     8     
                                  F     3   
                                  G     1    

通过PKG和ITEM连接上面的两个表后,我得到以下结果

After connecting the 2 above tables by PKG and ITEM i get the following result

 Item  Value  Bulk  PKG
   A     2 
   B     1
   C     4
   D     5      A     D
   E     8      A     E
   F     3      B     F
   G     1      C     G

如您所见前三个值,因为它是通过pkg连接的,并且这些值是批量值。

As you can see nothing shows up for the first 3 values since it is connected by pkg and those are "Bulk" values.

我正在尝试创建一个使用交叉引用表的新列

I am trying to create a new column that uses the cross reference table

我想创建以下内容

      Item  Value  Bulk  PKG   NEW COLUMN
        A     2                    5
        B     1                    3
        C     4                    1
        D     5      A     D       5.75
        E     8      A     E       9.2
        F     3      B     F       3.45
        G     1      C     G       1.15

新列是我要创建的内容。

The new column is what I am trying to create.

我希望原始值在批量显示时显示为pkg。然后,我希望Pkg项比原始值高15%。

I want the original values to show up for bulk as they appear for pkg. I then want the Pkg items to be 15% higher than the original value.

如何根据设置来计算?

推荐答案

只需在查询编辑器中编写条件自定义列:

Just write a conditional custom column in the query editor:

New Column = if [Bulk] = null then [Value] else 1.15 * [Value]

您也可以将其作为DAX计算列:

You can also do this as a DAX calculated column:

New Column = IF( ISBLANK( Table1[Bulk] ), Table1[Value], 1.15 * Table1[Value] )

这篇关于基于另一列的条件计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆