用于从特定 ID 中选择值并乘以具有相同名称的其余值的自动公式

编程入门 行业动态 更新时间:2024-10-26 09:33:58
本文介绍了用于从特定 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 文件:pwrbi/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 文件:pwrbi/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: pwrbi/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: pwrbi/so_55916210-2/

更多推荐

用于从特定 ID 中选择值并乘以具有相同名称的其余值的自动公式

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

发布评论

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

>www.elefans.com

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