如何仅在过滤后的记录上使用 power bi 中的 MAX 函数? [英] How to I use the MAX function in power bi only on the filtered records?

查看:63
本文介绍了如何仅在过滤后的记录上使用 power bi 中的 MAX 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试选择日期最近的记录,数据库中的所有记录都有这些基本列 AssetNumber、WorkOrderNumber、ScheduledEndDate、Department

I am trying to select the record with the latest date, all of the records in the database have these basic columns AssetNumber, WorkOrderNumber, ScheduledEndDate, Department

我想查找特定部门中每项资产的所有最新工单日期".我有一个基本的措施和专栏来做到这一点,但它不起作用.

I want to find all the latest work order "date" for each asset in a specific department. I have a basic measure and column to do this but it is not working.

如何过滤记录然后应用最大日期函数.我尝试过使用 ALL、ALLEXCEPT、ALLSELECTED 等.

How do I filter the records and then apply the max date function. I have tried using ALL, ALLEXCEPT, ALLSELECTED etc.

| ASSET | DEPARTMENT | WOSCHED_ENDDATE |
|-------|------------|-----------------|
| 2160  | 57257E     | 11/29/2011      |
| 2160  | 57257E     | 7/28/2014       |
| 6440  | 57257E     | 3/5/2012        |
| 6440  | 57257E     | 3/9/2015        |

在基本级别上,我需要从我的视觉对象中删除具有旧日期的两条记录.我可以找到整个列的最新 (MAX) 日期,但我无法让 MAX 函数在过滤值的上下文中工作,这些过滤值按我在示例网格中的部门划分.

At the basic level I need to remove the two records with the old dates from my visual. I can find the most recent (MAX) date of the entire column but I cannot get the MAX function to work in the context of the filtered values which by department like I have in the sample grid.

谢谢

推荐答案

尝试创建度量:

MaxDate =
CALCULATE (
    MAX ( 'Data_Mart'[WOSCHED_ENDDATE] ),
    ALLSELECTED ( 'Data_Mart'[WOSCHED_ENDDATE] )
)

我觉得很简单:

MaxDate = MAX( 'Data_Mart'[WOSCHED_ENDDATE] ) 应该可以工作.

在 Power BI 中使用矩阵我得到:

In Power BI using a matrix I get:

注意 WOSCHED_ENDDATE 不包含在矩阵中,如果包含它,则将对每行评估度量,因此 MaxDate 度量将在每行中给出相同的日期.

Note WOSCHED_ENDDATE is not included in the matrix if you include it the measure will be evaluated per each row so the MaxDate measure will give the same date in each row.

如果这有帮助,请告诉我.

Let me know if this helps.

这篇关于如何仅在过滤后的记录上使用 power bi 中的 MAX 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆