Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/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
Excel 连续日期选择SAMEPERIODLASTYEAR_Excel_Powerbi_Powerpivot_Dax - Fatal编程技术网

Excel 连续日期选择SAMEPERIODLASTYEAR

Excel 连续日期选择SAMEPERIODLASTYEAR,excel,powerbi,powerpivot,dax,Excel,Powerbi,Powerpivot,Dax,我陷入了一个非常-我认为-简单的问题,不知何故现在对我工作了。我创建了一个计算从2014年开始的过去几年零售额的指标: Retails := CALCULATE(COUNT(fData[ProductionNumber);fData[OrderStatus]=50)) 其次,我们的数据模型由2014年1月1日至2018年12月31日的日历表组成 为了进行年度比较,我将“上一年度零售”定义为: PY Retails := CALCULATE([Retails];SAMEPERIODLASTYEA

我陷入了一个非常-我认为-简单的问题,不知何故现在对我工作了。我创建了一个计算从2014年开始的过去几年零售额的指标:

Retails := CALCULATE(COUNT(fData[ProductionNumber);fData[OrderStatus]=50))
其次,我们的数据模型由2014年1月1日至2018年12月31日的日历表组成

为了进行年度比较,我将“上一年度零售”定义为:

PY Retails := CALCULATE([Retails];SAMEPERIODLASTYEAR('Date'[DateKey])
不知怎的,这让我陷入了“连续日期选择”的境地——错误,我不知道为什么或者如何!使用此方法计算PY销售额一直有效。无论如何,在这种情况下,它没有。我已经检查了我的事实表,每个日期都包含在日历日期键中。我在想,这可能与2016年2月29日有一家零售店的事实有关,然后当向后移动时,它在2015年找不到相同的日期


谢谢你的帮助

您感到困惑是对的-这是SAMEPERIODLASTYEAR函数的一个相当愚蠢的弱点。为了避免它,我通常用IF。。。选择价值测试以避免跨越多年,例如

PY Retails := IF ( SELECTEDVALUE ( 'Date'[Year]; 0 ) = 0 ; BLANK() ;  CALCULATE([Retails];SAMEPERIODLASTYEAR('Date'[DateKey]) )