powerbi - 如何使用时间变量增强组合代码
问题描述
我通过 v-shex-msft 找到了以下代码,我想用它来提供一个组合列表。向他致敬。现在我想添加一个时间变量,以便仅组合 24 小时内发生的事件。不幸的是,过滤器功能不允许我使用更多参数:
原始代码:
Summary Table =
var temp=
SUMMARIZE(
Sheet5,
Sheet5[Customer],
"Combinations",CONCATENATEX(
FILTER(
SUMMARIZE(
Sheet5,
[Customer],
Sheet5[Type]
),
Sheet5[Customer] = EARLIER(Sheet5[Customer])
),
[Type]&","
)
)
return
SUMMARIZE(
temp,
[combinations],
"Number",COUNTAX(
FILTER(
temp,
[combinations]=EARLIER([combinations])
),
[Customer]
)
)
我尝试按如下方式添加时间变量:
Summary Table =
var temp =
SUMMARIZE(
Sheet5,
Sheet5[Customer],
"Combinations",CONCATENATEX(
FILTER(
SUMMARIZE(
Sheet5,
[Customer],
Sheet5[Type],
Sheets5[time]
),
Sheet5[Customer] = EARLIER(Sheet5[Customer])
&& Sheets5[time]+1 >= Earlier(Sheets5[time])
&& Sheets5[time]-1 <= Earlier(Sheets5[time])
),
[Type]&","
)
)
return
SUMMARIZE(
temp,
[combinations],
"Number",COUNTAX(
FILTER(
temp,
[combinations] = EARLIER([combinations])
),
[Customer]
)
)
关于出了什么问题的任何想法?非常感谢您的帮助。
解决方案
你可以试试下面的代码 -
Summary Table =
var temp =
SUMMARIZE(
Sheet5,
Sheet5[Customer],
"Combinations",CONCATENATEX(
FILTER(
SUMMARIZE(
Sheet5,
[Customer],
Sheet5[Type],
Sheets5[time]
),
MAX(Sheet5[Customer]) = EARLIER(Sheet5[Customer])
&& MAX(Sheets5[time]) +1 >= Earlier(Sheets5[time])
&& MAX(Sheets5[time]) -1 <= Earlier(Sheets5[time])
),
[Type]&","
)
)
return
SUMMARIZE(
temp,
[combinations],
"Number",COUNTAX(
FILTER(
temp,
[combinations] = EARLIER([combinations])
),
[Customer]
)
)
推荐阅读
- java - 我怎样才能写清单
以课堂形式 - python - 模块 jupyter-vuetify semver 范围未注册为小部件模块
- php - Laravel 本地化嵌套 JSON 语言文件
- android - Android - 使用 ViewPager2 设置 setOffscreenPageLimit 会导致屏幕在方向更改时失真
- java - 覆盖 REST API 中的特定资源
- c# - 合并两个列表并排序
- vue.js - bootstrap-vue 表,Formatter 回调错误:您可能在组件渲染函数中有无限更新循环
- java - 如何打开安卓设备的前置手电筒(不是后置手电筒)
- angular - 如何在角度 11 的一个角度配置文件中配置所有所有 api url
- c - 我在 Windows 10 上找不到 /rootfs