PowerBI:获取每个位置和日期的 District max
PowerBI: Get District max per location and date
我看过所有关于此问题的帖子,但其中 none 个帖子适用于以下问题。
table很简单:
Source - Quantity - DateTime
DS01 100 01/10/19 08:00
DS01 90 01/10/19 08:25
DS01 80 01/10/19 08:30
DS02 3000 01/09/19 18:45
DS02 2000 01/10/19 08:10
DS02 1800 01/10/19 08:30
DS02 1200 01/10/19 08:45
DS03 45000 10/09/19 17:30
DS03 30000 10/10/19 12:11
DS03 10000 11/22/19 17:30
我需要获取最新日期时间的值,因此输出为:
DS03 10000 11/22/19 17:30
DS02 1200 01/10/19 08:45
DS01 80 01/10/19 08:30
最好的方法是什么?
您可以使用 SUMMARIZECOLUMNS
创建具有所需输出的 table:
Output Table =
SUMMARIZECOLUMNS (
MyTable[Source],
"Latest Quantity",
VAR MaxDate = MAX ( MyTable[DateTime] )
RETURN
CALCULATE (
VALUES ( MyTable[Quantity] ),
MyTable[DateTime] = MaxDate
),
"Latest Date",
MAX ( MyTable[DateTime] )
)
在此处下载示例 PBIX 文件:https://pwrbi.com/so_58839916/
我用不同的方式整理出来:
首先我找到了 "Most Recent Date":
TableGroup = GROUPBY(YOUR_DATASET,YOUR_DATASET[来源],"Most Recent Date",MAXX(CURRENTGROUP(),YOUR_DATASET[DateTime]))
在我将相关数量添加到我的 "Most Recent Date" 和数据源之后:
Qty = CALCULATE(maxx(YOUR_DATASET,YOUR_DATASET[数量]),FILTER(YOUR_DATASET,YOUR_DATASET[来源] = TableGroup[YOUR_DATASET_来源]), FILTER(YOUR_DATASET, YOUR_DATASET[DateTime] = TableGroup[最近日期]))
This is my dataset:
和
this is the resultset:
我看过所有关于此问题的帖子,但其中 none 个帖子适用于以下问题。
table很简单:
Source - Quantity - DateTime
DS01 100 01/10/19 08:00
DS01 90 01/10/19 08:25
DS01 80 01/10/19 08:30
DS02 3000 01/09/19 18:45
DS02 2000 01/10/19 08:10
DS02 1800 01/10/19 08:30
DS02 1200 01/10/19 08:45
DS03 45000 10/09/19 17:30
DS03 30000 10/10/19 12:11
DS03 10000 11/22/19 17:30
我需要获取最新日期时间的值,因此输出为:
DS03 10000 11/22/19 17:30
DS02 1200 01/10/19 08:45
DS01 80 01/10/19 08:30
最好的方法是什么?
您可以使用 SUMMARIZECOLUMNS
创建具有所需输出的 table:
Output Table =
SUMMARIZECOLUMNS (
MyTable[Source],
"Latest Quantity",
VAR MaxDate = MAX ( MyTable[DateTime] )
RETURN
CALCULATE (
VALUES ( MyTable[Quantity] ),
MyTable[DateTime] = MaxDate
),
"Latest Date",
MAX ( MyTable[DateTime] )
)
在此处下载示例 PBIX 文件:https://pwrbi.com/so_58839916/
我用不同的方式整理出来:
首先我找到了 "Most Recent Date": TableGroup = GROUPBY(YOUR_DATASET,YOUR_DATASET[来源],"Most Recent Date",MAXX(CURRENTGROUP(),YOUR_DATASET[DateTime]))
在我将相关数量添加到我的 "Most Recent Date" 和数据源之后: Qty = CALCULATE(maxx(YOUR_DATASET,YOUR_DATASET[数量]),FILTER(YOUR_DATASET,YOUR_DATASET[来源] = TableGroup[YOUR_DATASET_来源]), FILTER(YOUR_DATASET, YOUR_DATASET[DateTime] = TableGroup[最近日期]))
This is my dataset:
和
this is the resultset: