是否可以将 DAX 函数转换为 Measure,以便我可以使用切片器进行过滤?

Is it possible to convert DAX functions into a Measure so I can filter with a slicer?

我刚刚接触 DAX 等,我知道我正在寻找的解决方案可能非常简单和优雅,但它处于我知识的边缘。

我真的希望你能帮助我:)

我正在处理的数据是一大堆声明。

'Claim ID''Ready for Review''Complete'

时,数据给出 Timestamp

由于业务的性质,有时索赔会在“完成”后返回到 'Ready for Review',因此一些 'Claim ID' 可以有多行标记为 'Ready for Review'.

现在我有三个 DAX 函数来计算索赔当前是否 'Ready for Review'

Columns and such:

RFE State History is the table

Timestamp gives the date and time down to the second

Claim Id is the claim number

Status Label will either be "Ready for Review" or "Complete"

MaxDate: =
CALCULATE (
    MAX ( 'RFE State History'[Timestamp] ),
    FILTER (
        'RFE State History',
        'RFE State History'[Claim Id] = EARLIER ( 'RFE State History'[Claim Id] )
    )
)

这按索赔编号过滤,然后输出批次的最新日期。

IsLatest: =
IF('RFE State History'[Timestamp]='RFE State History'[MaxDate],"Latest")

MaxDate值等于这一行的日期时,输出"Latest"

Ready for Review: =
IF (
    'RFE State History'[Status Label] = "Ready for Review"
        && 'RFE State History'[IsLatest] = "Latest",
    1
)

IsLatest列为“Latest”时,输出“1”


然后我在 Pivot Table 中使用 'Redy for Review' 来总结在那个特定时刻有多少索赔是 Ready to Review

我需要从这里做的事情:

我希望能够使用切片器来判断在过去的任何特定日期有多少索赔 Ready to Reiew(并且单独:在一天中的每个小时,以便我们可以跟踪整个过程那天)。

在谷歌搜索了几个星期后,我 运行 找到了这些:

~Is it possible to use a slicer as a parameter to a DAX Summarize function?

~DAX Fridays! #93: MAXX | Fill down with DAX and Power Query (YouTube)

~This blog entry on SUMMARIZECOLUMNS

~This PowerBI Post on SUMMARIZECOLUMNS

这让我相信我需要编写一个基本上同时使用 FILTER 执行三个 DAX 函数(MaxDateIsLatestReady for Review)的 Measure和 SUMMARIZECOLUMNS,以便可以使用切片器对其进行过滤。

就像我在上面所说的那样:我很确定解决方案非常简单;我已经尝试过使它们适应一种没有运气的措施。我才真正开始接触 DAX 世界,所以我知道有很多我不知道并且还没有完全掌握的东西。

我真的希望你能帮我指出正确的方向。

提前致谢:)

如果我没理解错的话,您想计算在您使用切片器选择的给定日期或时间的“准备好审核”声明的数量?

如果是这种情况,您可以:

  1. 使用以下代码创建一个新的计算 table。您可以在建模菜单中计算列的按钮旁边找到它

    DateTime = 
    ADDCOLUMNS (
        CROSSJOIN (
            CALENDAR ( DATE ( 2000, 1, 1 ), DATE ( 2025, 12, 31 ) ),
            UNION (
                ROW ( "Time", TIME ( 1, 0, 0 ) ),
                ROW ( "Time", TIME ( 2, 0, 0 ) ),
                ROW ( "Time", TIME ( 3, 0, 0 ) ),
                ROW ( "Time", TIME ( 4, 0, 0 ) ),
                ROW ( "Time", TIME ( 5, 0, 0 ) ),
                ROW ( "Time", TIME ( 6, 0, 0 ) ),
                ROW ( "Time", TIME ( 7, 0, 0 ) ),
                ROW ( "Time", TIME ( 9, 0, 0 ) ),
                ROW ( "Time", TIME ( 10, 0, 0 ) ),
                ROW ( "Time", TIME ( 11, 0, 0 ) ),
                ROW ( "Time", TIME ( 12, 0, 0 ) ),
                ROW ( "Time", TIME ( 13, 0, 0 ) ),
                ROW ( "Time", TIME ( 14, 0, 0 ) ),
                ROW ( "Time", TIME ( 15, 0, 0 ) ),
                ROW ( "Time", TIME ( 16, 0, 0 ) ),
                ROW ( "Time", TIME ( 17, 0, 0 ) ),
                ROW ( "Time", TIME ( 18, 0, 0 ) ),
                ROW ( "Time", TIME ( 19, 0, 0 ) ),
                ROW ( "Time", TIME ( 20, 0, 0 ) ),
                ROW ( "Time", TIME ( 21, 0, 0 ) ),
                ROW ( "Time", TIME ( 22, 0, 0 ) ),
                ROW ( "Time", TIME ( 23, 0, 0 ) ),
                ROW ( "Time", TIME ( 24, 0, 0 ) )
            )
        ),
        "DateTime", [Date] + [Time],
        "Hour", HOUR ( [Time] )
    )
    

感谢您在此post中的回答:https://community.powerbi.com/t5/Desktop/how-to-build-a-calendar-table-with-date-and-time/td-p/241728

  1. 为您之前的计算创建一个度量

    Ready for Review = 
    var _selectedPeriod = MAX ( DateTime[DateTime] ) // Grab DateTime from the selected value in DateTime. This can be a single value or the end of a period. Default is last available date in DateTime
    RETURN
        COUNTX (
            'RFE State History' ,
            var _maxDate =
                CALCULATE(
                    MAX ( 'RFE State History'[Timestamp] ) ,
                    ALL ( 'RFE State History' ) , 
                    'RFE State History'[Claim Id] = EARLIER( 'RFE State History'[Claim Id] ) ,
                    'RFE State History'[Timestamp] <= _selectedPeriod             
                )
    
            var _isLast = 
                _maxDate = 'RFE State History'[Timestamp]
    
            RETURN
                IF( AND ( _isLast = TRUE() , 'RFE State History'[Status Label] = "Ready for Review" ) , 1 )
        )
    
  2. 使用日历中的 DateTime 创建一个切片器 table 并使用上面生成的度量值进行可视化