Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date 非标准月份的功率双日期计算_Date_Dax_Powerbi Desktop - Fatal编程技术网

Date 非标准月份的功率双日期计算

Date 非标准月份的功率双日期计算,date,dax,powerbi-desktop,Date,Dax,Powerbi Desktop,Power BI桌面 版本:2.73.5586.984 64位(2019年9月) 我正在创建一个计算列,以确定票据是否已在“当前”或“积压”状态下完成。我们的报告期为每月26日至25日。如果票证在报告期m/26-m/25内完成,则视为“当前”。如果票证在该时间范围外完成,则为“积压”。此外,如果当前票证尚未完成,但仍有可能在同一报告期内完成,则该票证将被列为“当前”,但如果它继续到下一个报告月,那么它将是“积压” 示例: 2021年1月1日创建和2021年10月1日完成=当前 2021年1月1日

Power BI桌面
版本:2.73.5586.984 64位(2019年9月)

我正在创建一个计算列,以确定票据是否已在“当前”或“积压”状态下完成。我们的报告期为每月26日至25日。如果票证在报告期m/26-m/25内完成,则视为“当前”。如果票证在该时间范围外完成,则为“积压”。此外,如果当前票证尚未完成,但仍有可能在同一报告期内完成,则该票证将被列为“当前”,但如果它继续到下一个报告月,那么它将是“积压”

示例:
2021年1月1日创建和2021年10月1日完成=当前
2021年1月1日创建和2021年3月18日完成=积压工作
2021年1月25日创建和2021年1月26日完成=积压工作
创建于2021年4月20日&未完成&今天[2021年4月30日]=积压工作
创建于2021年4月29日,未完成,今天[4/30/2021]=当前

我已经编写了下面的DAX来处理这个问题,但我似乎在报告期结束/开始时遇到了问题,计算不正常,所有内容都列为当前或积压

我的日期表中还有一个helper列,用于确定当前报告期基于当前日期的内容,但我没有在这个公式中使用它,但如果它能提高效率,我可以使用它

这样做的更好/正确的方法是什么

当前/积压计算列:

Current_Backlog = 

VAR CreatedDay = Day(IR_SR[Created_Date])
VAR CompletedDay = Day(IR_SR[Completed_Date])
VAR CreatedMonth = Month(IR_SR[Created_Date])
VAR CompletedMonth = Month(IR_SR[Completed_Date])
VAR CreatedMonthAdd = Month(IR_SR[Created_Date])+1
VAR CompletedMonthAdd = Month(IR_SR[Completed_Date])+1
VAR CurrentMonth = Month(TODAY())
VAR CurrentMonthAdd = Month(TODAY())+1
VAR CurrentDay = Day(TODAY())

RETURN
//If the date the ticket was completed is before the 26th and the created and completed month match, mark as current
IF(CompletedDay < 26 && CreatedMonth = CompletedMonth, "Current",
    //If the completed date is after or equal to the 26th see if the created month plus one and completed month plus one match, mark as current
    IF(CreatedDay >= 26 && CompletedDay >= 26 && CreatedMonthAdd = CompletedMonthAdd, "Current",
        //If the completed date is after or equal to the 26th and the created date is after or equal to the 26th see if the created and completed month plus one match, mark as current
        IF(CreatedDay >= 26 && CreatedMonthAdd = CompletedMonth, "Current",
            //If the ticket is not completed and the created date is less then the 26th and the created month and current month match, mark as current
            IF(IR_SR[Open/Closed] = "Open" && CurrentDay < 26 && CreatedDay < 26 && CreatedMonth = CurrentMonth, "Current",
                //If the ticket is not completed and the created date is greater then the 26th and the created month and current month match plus one, mark as current
                IF(IR_SR[Open/Closed] = "Open" && CurrentDay >= 26 && CurrentDay < 1 && CreatedDay >= 26 && CreatedMonthAdd = CurrentMonthAdd, "Current",
                    IF(IR_SR[Open/Closed] = "Open" && CurrentDay < 26 && CurrentDay >= 1 && CreatedDay >= 26 && CreatedMonthAdd = CurrentMonth, "Current",
                    "Backlog"))))))

在这种情况下的建议。在Power BI内的性能分析器中比较两个DAX公式,并检查计算花费的时间。 我猜您的所有数据都被导入了,在这种情况下,数据被缓存了,所以关于性能的第一个问题就解决了。 无论如何,粘贴DAX代码的第二部分,我会检查它。
谢谢你的回复。我很感激关于性能的建议,但我更希望找到一个更好的解决方案,因为这个方案并不完全有效。例如,所有尚未完成的票据都以“Backlog”状态显示,即使其中一些票据应该处于“Current”状态。
= Table.AddColumn(#"Inserted Day Name", "Reporting_Period", each if Date.Day([Date]) >= 26
then Date.StartOfMonth(Date.AddMonths([Date], 1))
else Date.StartOfMonth([Date]))