首页 > 解决方案 > Power BI Dax Group By Measure - 显示今天之前的日期

问题描述

我正在尝试创建一个度量,该度量将显示一段时间内的预订收入,按几个类别分组。当数据为 BLANK() 时,我还想在折线图中显示为 0,因此我将其放在 IF 语句中。一切都很好,除了出于某种原因我不能让它只显示今天之前的日期。

折线图 这是当前的措施:

M_BookedRevenue = 
VAR CurrentAccountingYear =
    CALCULATE ( MIN ( 'Date'[AccountingYear] ), 'Date'[Date] = TODAY () )
VAR CurrentDate =
    CALCULATE ( MIN ( 'Date'[SortDate] ), 'Date'[Date] = TODAY() )
RETURN
    CALCULATE (
    IF (
        ISBLANK (
            SUMX (
                FILTER (
                    GROUPBY (
                        RevenueChannel,
                        RevenueChannel[ChannelBucket],
                        RevenueChannel[Channel],
                        'Date'[Date],
                        'Date'[SortDate],
                        'Date'[AccountingWeek],
                        'Date'[WeekNumber],
                        'Date'[AccountingMonthEnglishAbbrYear],
                        'Date'[AccountingMonth],
                        'Date'[AccountingYear],
                        "Revenue", SUMX ( CURRENTGROUP (), RevenueChannel[TransactionRevenue] )
                    ),
                    'Date'[AccountingYear] >= CurrentAccountingYear
                    && 'Date'[SortDate] < CurrentDate
                ),
                [Revenue]
            )
        ),
        0,
        SUMX (
            FILTER (
                GROUPBY (
                    RevenueChannel,
                    RevenueChannel[ChannelBucket],
                    RevenueChannel[Channel],
                    'Date'[Date],
                    'Date'[SortDate],
                    'Date'[AccountingWeek],
                    'Date'[WeekNumber],
                    'Date'[AccountingMonthEnglishAbbrYear],
                    'Date'[AccountingMonth],
                    'Date'[AccountingYear],
                    "Revenue", SUMX ( CURRENTGROUP (), RevenueChannel[TransactionRevenue] )
                ),
                'Date'[AccountingYear] >= CurrentAccountingYear
                && 'Date'[SortDate] < CurrentDate
            ),
            [Revenue]
        )
    )
)

标签: powerbidaxmeasure

解决方案


推荐阅读