PowerBI 筛选器

编程入门 行业动态 更新时间:2024-10-24 06:35:37
本文介绍了PowerBI 筛选器-在开始和结束日期之间选择日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在从包含开始和结束日期的数据集构建 PowerBI 报告.我想根据包含另一个表中选定日期的行来过滤数据集.

I'm building a PowerBI report from a dataset that contains start and end dates. I'd like to filter the dataset based on rows that would encompass a selected date in another table.

此处的屏幕截图显示了一个示例.我想单击右侧表格中的日期,然后过滤左侧表格,其中所选日期介于开始日期和日期之间.结束日期.

The screenshot here shows a sample. I want to click a date in the table on the right and have the table on the left filtered where the selected date is between the start & end date.

我使用列和度量尝试了几种不同的方法,但一直无法确定.我还尝试从引用所选日期的 DAX 表达式创建一个新表,但这导致了错误.

I've attempted several different things using columns and measures, but I haven't been able to nail it down. I also attempted to create a new table from a DAX expression that references the selected date, but that caused errors.

如何根据所选日期介于开始和结束日期值之间动态过滤数据集?

How can I dynamically filter the dataset based on the selected date being between the start and end date values?

推荐答案

创建度量以检查行是否与所选日期范围重叠:

Create a measure to check whether a row overlaps the selected date range:

Date Included = IF ( FIRSTNONBLANK ( Table1[Start Date], 1 ) <= MAX ( 'Calendar'[Date] ) && FIRSTNONBLANK( Table1[End Date], 1 ) >= MIN ( 'Calendar'[Date] ), "Include", "Exclude" )

将此度量添加为可视化的过滤器,其中 Date Included 是 Include

Add this Measure as a filter on your visualisation, where Date Included is Include

现在您可以过滤日历表(过滤到单个值或范围),并且只会显示事实表中的重叠行.

Now you can filter your Calendar table ( to single value, or range), and only overlapping rows from your fact table will be displayed.

请参阅 pwrbi/so_55925954/ 获取工作示例 PBIX 文件

See pwrbi/so_55925954/ for worked example PBIX file

更多推荐

PowerBI 筛选器

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

发布评论

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

>www.elefans.com

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