如何替换DAX计算列中的EARLIER函数?

问题描述 投票:0回答:1

我最近读到,你不应该使用 EARLIER 函数。我最近继承了一个使用此函数的数据集文件,并且它不断崩溃,可能是由于 EARLIER 函数。我正在尝试使用变量将此公式转换为正确的格式,但遇到了一些麻烦。

当前代码的设置如下,以获得截至最近发票的累积余额。我如何调整它以删除 EARLIER 函数但得到相同的结果?

_Balance Cumulative =
calculate(sum(Invoices[Balance]),
          ALLEXCEPT(Invoices,Invoices[Customer ID + Company Desc]),
          filter(
             all(Invoices[Invoice Date]),Invoices[Invoice Date] <= 
                 EARLIER(Invoices[Invoice Date])))
powerbi dax calculated-columns
1个回答
0
投票

上周,我也在解决这个问题。解决方案是创建一个新表。您可以使用“汇总”功能。让我分享我的 DAX 代码,您可以更改您的属性。

//Attributes
//'Invoices table'[Line Job]=Invoice ID (use unique values without blank)
//'Invoices table'[Account]=Invoice Account (use account which has earliest invoice date)
//'Invoices table'[Total]=Invoice Amount (sum amount which has earliest invoice date)
//'Invoices table'[Invoice Date]=Invoice Date

Earliest Invoice Date = 
SUMMARIZE (
    FILTER('Invoices table', NOT(ISBLANK('Invoices table'[Line Job]))),
    'Invoices table'[Line Job]
    ,"Client" , CALCULATE(MIN('Invoices table'[Account]), 'Invoices table'[Invoice Date]= MIN('Invoices table'[Invoice Date]) )
    ,"Total Amount", CALCULATE(SUM('Invoices table'[Total]), 'Invoices table'[Invoice Date]= MIN('Invoices table'[Invoice Date]) ) 
    ,"Earliest Invoice Date", CALCULATE(
        MIN('Invoices table'[Invoice Date]),
        ALLEXCEPT('Invoices table', 'Invoices table'[Line Job])
    )
    
)

希望对你有帮助😊

© www.soinside.com 2019 - 2024. All rights reserved.