简体   繁体   English

PowerPivot,数据模型,可从数据输入表中选择单独表中的日期列表

[英]PowerPivot, Data Model to select from a data entry table against a list of dates in a separate table

Apologizes for perhaps asking a too-simple question, but I'm unable to solve my problem. 很抱歉提出了一个过于简单的问题,但我无法解决我的问题。

I would like to display a running balance of scheduled production yields , lets just say in gallons of milk. 我想显示计划产量的平衡,让我们说加仑牛奶。

I have an entry table that I schedule my milk, and it has absolutely nothing unique about it, The names, start dates, end dates, batch numbers, everything are not unique. 我有一个计划奶的条目表,它绝对没有任何独特之处,名称,开始日期,结束日期,批号,所有内容都不是唯一的。

And so now I want to forecast my yields here with dates, but I also want to see how much milk I might sell on a date that does not exist in the entry table. 所以现在我想用日期来预测我的产量, 我也想看看在输入表中不存在的日期我可以卖出多少牛奶。

My thought is to create a list of the dates I want to pick, and the table will go looking for the values. 我的想法是创建一个我要选择的日期的列表,然后表格将在其中寻找值。 But, because my Data Entry Table is completely unique, the only thing I can do is associate the Data Entry Table with my Selected Dates, backwards in a way that does nothing. 但是,由于我的数据条目表是完全唯一的,因此我唯一可以做的就是将数据条目表与我的选定日期相关联,以一种不执行任何操作的方式向后关联。

我的数据模型,目前没有组织,没有按照我的意愿做

这是结果

Currently the data model is 'working' for what I told it to do, but what I really want to do is instead of using Packing Date (Scenario) , I want to use 'Date Picks'[Dates Between] , because I want to see dailies, every day, not just only my entry dates. 目前,数据模型正在“按要求执行”工作,但是我真正想做的不是使用“ 装箱日期(场景)” ,而是要使用“日期选择” [日期之间] ,因为我想每天看到的不仅是我的入职日期,还包括每天。

When I place 'Date Picks'[Dates Between] in the columns instead of Packing Date (Scenario) , I get #N/A and stuff obviously because my relationship is backwards. 当我在列中放置“ Date Picks” [Date Between]而不是“ Packing Date”(方案)时 ,由于我的关系向后,所以我得到了#N / A和其他东西。

The issue is, I can't change the relationship direction because it's an Entry table and there's nothing unique inside of it, let alone anything unique I can associate with 'Date Picks' 问题是,我无法更改关系方向,因为它是一个Entry表,并且里面没有任何独特之处,更不用说我可以与“ Date Picks”关联的任何独特之处了

This is how I ended up organizing my data Model: 这就是我最终组织数据模型的方式:

工作数据模型

Besides the successful change of the "filtering flow" or "relationship flow" of the data model, I created a whole new table named Will Sell that contains every date in Selected Dates , every name in Selected Names , and every daily sales in Will Start . 除了成功更改数据模型的“过滤流”或“关系流”之外,我还创建了一个名为Will Sell全新表,该表包含Selected Dates中的每个Selected DatesSelected Names每个名称以及Will Start每个日常销售额。 。

How I created Will Sell is not very clean, 我如何创建Will Sell不是很干净,

I created a flattened pivot table with all of the aforementioned fields as Rows, 我创建了一个扁平化的数据透视表,其中所有上述字段都作为“行”,

and then created the formula =IF(C2 <> 0, C2, "") to pull data from that flattened PivotTable into individual cells that make up a standard table. 然后创建公式=IF(C2 <> 0, C2, "") ,将数据从展平的数据透视表中提取到组成标准表的各个单元格中。 I then pull that standard table into PowerPivot as Will Sell 然后,我Will Sell标准表拉入PowerPivot,因为Will Sell

In case anyone may be interested my measures are the following: 如果有人可能感兴趣,我的措施如下:

Running Sales: 营业额:

=CALCULATE(SUM('Will Sell'[Sales (Daily, Average)]),

FILTER(ALL('Selected Dates'[Controller Dates]), 'Selected Dates'[Controller Dates] <= MAX( 'Selected Dates'[Controller Dates])))

Running Have: 跑步有:

=CALCULATE(
SUM('Will Package'[Yield (Gallons)]),

FILTER(ALL('Selected Dates'[Controller Dates]), 
 'Selected Dates'[Controller Dates] <= MAX( 'Selected Dates'[Controller Dates])),

 FILTER(ALL('Will Package'[Packaged?]),
 'Will Package'[Packaged?] = FALSE)

 )+[Static Starting Gallons]

Running Balance: 营运余额:

=IF([Running Have] <= [Running Sales], 0, [Running Have]-[Running Sales])

Running Balance (Fixed): 流动余额(固定):

=IF(COUNTROWS(VALUES('Selected Names'[Product Name]))=1,
   [Running Balance],
   SUMX(VALUES('Selected Names'[Product Name]), [Running Balance])
)

I'm using the Running Balance (fixed) instead of Running Balance because the fixed measure calculates the Grand Total properly whereas the other one does not. 我使用的是“ Running Balance (fixed)而不是“ Running Balance因为固定量度可以正确计算“总计”,而另一项则不能。

Here are my results, which are desired: 这是我想要的结果:

工作结果!

The dates on the left are Week Ending dates, the meat in the middle is the predicted future inventory over time, and the far right darkest column is the grand total. 左边的日期是“周末”日期,中间的肉是随着时间的推移将来的预计库存量,最右边的最暗的列是总计。

Very happy with my prediction model! 我的预测模型非常满意!

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

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