简体   繁体   English

Power BI - 从 Measure 创建表

[英]Power BI - Create table from Measure

In Power BI I have a list of inventory transactions (InventTrans) with date, quantity and value for movements in and out of the inventory.在 Power BI 中,我有一个库存交易 (InventTrans) 列表,其中包含进出库存的日期、数量和价值。

There are 1 million lines of inventory transactions, and the sum of all lines for each ItemID gives the inventory value of that item.有 100 万行库存交易记录,每个 ItemID 的所有行的总和给出了该项目的库存价值。

I have created a measure to calculate number of days from last movement until today:我创建了一个度量来计算从上次移动到今天的天数:

Days since last movement = DATEDIFF(CALCULATE(MAX(InventTrans[Date]),TODAY(),DAY)自上次移动以来的天数 = DATEDIFF(CALCULATE(MAX(InventTrans[Date]),TODAY(),DAY)

and a measure (InventoryStatus) to group each ItemID based on this result.以及根据此结果对每个 ItemID 进行分组的度量 (InventoryStatus)。

I have used InventoryStatus = IF([Days since last movement]<183, "Movement last six months", ("Six months to a year", "Over 1 year". and so on)我使用了 InventoryStatus = IF([自上次移动以来的天数]<183,“最近六个月的移动”,(“六个月到一年”,“超过 1 年”等等)

Now I want to create a table with ItemID and the measure InventoryStatus.现在我想创建一个包含 ItemID 和 InventoryStatus 度量的表。 My aim is to use InventoryStatus as a filter, so maybe there is better way to achieve this without creating a new table with ItemID and InventoryStatus.我的目标是将 InventoryStatus 用作过滤器,因此也许有更好的方法可以实现此目的而无需使用 ItemID 和 InventoryStatus 创建新表。

Assuming inventory status is a property of the item, not the transaction, your proposed approach is probably correct.假设库存状态是物品的属性,而不是交易的属性,您建议的方法可能是正确的。 The data model will be more intuitive and more efficient if you create an items table that has ItemID , InventoryStatus , and any other item-level data.如果您创建一个包含ItemIDInventoryStatus和任何其他项目级数据的items表,数据 model 将更加直观和高效。 After linking the two tables together InventoryStatus can be used as a filter for transactions.将两个表链接在一起后, InventoryStatus可用作事务过滤器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM