用于从特定 ID 中选择值并乘以具有相同名称的其余值的自动公式 [英] Automated formula to select values from a specifid ID and multiply to the rest with the same Name

查看:9
本文介绍了用于从特定 ID 中选择值并乘以具有相同名称的其余值的自动公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种方法来选择特定 ID,读取其值并在不同 ID 中查找所有具有相同名称的产品,并将第一个 ID X.values 乘以不同 ID 中其他产品的变量.

例如,我有以下数据:

并且我想选择 ID = 1234 来查找与 1234 的产品关联的所有卷.在其他 ID 中找到具有相同名称的产品并将 ID=1234 的每个产品卷乘以同名产品 X.另一个 ID 的值,如下所示:

谢谢

解决方案

在计算列中,您可以使用 LOOKUPVALUE 找到 ID 1234 的 Volume 和对应的 Product - 然后选择如何计算基于是否返回匹配值的输出:

新列 =VAR 查找 ID = 1234VAR LookupVolume =查找值 (表1[卷],表 1[ID],查找 ID,表 1[产品]、表 1[产品])返回表 1[X.Value] &"*" &如果 (ISBLANK(查找卷),表1[卷],查找卷)

工作示例 PBIX 文件:https://pwrbi.com/so_55916210/

编辑

更复杂的度量 - 不完全清楚您打算如何使用它,但这种方法会为 ID 值列表创建一个单独的表,用作切片器:

ID 列表 = DISTINCT ( Table1[ID] )

然后我们可以使用度量:

新措施 =总和(表格1,VAR 查找 ID =如果 (HASONEVALUE ( 'ID 列表'[ID] ),值('ID 列表'[ID]),空白的())VAR LookupProduct =如果 (HASONEVALUE ( Table1[Product] ),值(表 1[产品]),空白的())VAR 有效交易量 =计算 (总和(表 1[卷]),全部(表1),表 1[ID] = 查找 ID,表 1[产品] = 查找产品)返回表 1[X.值] *如果 (ISBLANK(有效音量),表1[卷],有效体积))

更新的 PBIX 文件:https://pwrbi.com/so_55916210-2/p>

I am trying to find a way to choose specific ID, have its values read and find all Products with the same name in different IDs and multiply the first ID X.values into a variable of the other products in different IDs.

so for example I have data below :

and I want to Choose ID = 1234 to find all the Volumes associated to the products of 1234. Find the products with the same name in other IDs and Multiply each Product volumes of ID=1234, into the same name product X.Value of the other ID, like Below :

Thanks

解决方案

In a calculated column, you can use LOOKUPVALUE to find the Volume for ID 1234 and the corresponding Product - then choose how to calculate your output based on whether a matching value was returned or not:

New Column = 
VAR LookupID = 1234
VAR LookupVolume = 
    LOOKUPVALUE ( 
        Table1[Volume],
        Table1[ID], LookupID,
        Table1[Product], Table1[Product]
    )
RETURN
    Table1[X.Value] & " * " & 
    IF ( 
        ISBLANK ( LookupVolume ),
        Table1[Volume],
        LookupVolume
    ) 

Worked example PBIX file: https://pwrbi.com/so_55916210/

EDIT

More complex as a measure - not entirely clear how you intend using it, but this approach creates a separate table for a list of ID values, to be used as a slicer:

ID List = DISTINCT ( Table1[ID] )

Then we can use measure:

New Measure = 
SUMX ( 
    Table1,
    VAR LookupID = 
        IF ( 
            HASONEVALUE ( 'ID List'[ID] ),
            VALUES ( 'ID List'[ID] ),
            BLANK()
        )
    VAR LookupProduct = 
        IF ( 
            HASONEVALUE ( Table1[Product] ),
            VALUES ( Table1[Product] ),
            BLANK()
        )
    VAR EffectiveVolume =
        CALCULATE ( 
            SUM ( Table1[Volume] ),
            ALL ( Table1 ),
            Table1[ID] = LookupID,
            Table1[Product] = LookupProduct
        )
    RETURN
    Table1[X.Value] * 
    IF ( 
        ISBLANK ( EffectiveVolume ),
        Table1[Volume],
        EffectiveVolume
    )
) 

Updated PBIX file: https://pwrbi.com/so_55916210-2/

这篇关于用于从特定 ID 中选择值并乘以具有相同名称的其余值的自动公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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