我对YTD有疑问。下表主要是用于解释,然后我分享我的措施。
+------+-----------+------------+---------+--------------+---------+-------------+--------+----------+----------------+
| | | Measure | Measure | Measure | Measure | Measure | Measure| Measure | Result |
+------+-----------+------------+---------+--------------+---------+-------------+--------+----------+----------------+
| Year | Month | TotalofOne | One | %OneTotalOne | Total2 | %timeTotal2 | Three | subtract | YTDofsubstract |
| 2019 | January | 66 | 3 | 0,0455 | 80 | 3,6364 | 5 | -1,3636 | -1,3636 |
| 2019 | February | 66 | 4 | 0,0606 | 80 | 4,8485 | 6 | -1,1515 | -2,5152 |
| 2019 | March | 66 | 5 | 0,0758 | 80 | 6,0606 | 7 | -0,9394 | -3,4545 |
| 2019 | April | 66 | 6 | 0,0909 | 80 | 7,2727 | 5 | 2,2727 | -1,1818 |
| 2019 | May | 66 | 7 | 0,1061 | 80 | 8,4848 | 6 | 2,4848 | 1,3030 |
| 2019 | June | 66 | 8 | 0,1212 | 80 | 9,6970 | 7 | 2,6970 | 4,0000 |
| 2019 | July | 66 | 5 | 0,0758 | 80 | 6,0606 | 5 | 1,0606 | 5,0606 |
| 2019 | August | 66 | 5 | 0,0758 | 80 | 6,0606 | 6 | 0,0606 | 5,1212 |
| 2019 | September | 66 | 7 | 0,1061 | 80 | 8,4848 | 7 | 1,4848 | 6,6061 |
| 2019 | October | 66 | 5 | 0,0758 | 80 | 6,0606 | 5 | 1,0606 | 7,6667 |
| 2019 | November | 66 | 5 | 0,0758 | 80 | 6,0606 | 6 | 0,0606 | 7,7273 |
| 2019 | December | 66 | 6 | 0,0909 | 80 | 7,2727 | 7 | 0,2727 | 8,0000 |
+------+-----------+------------+---------+--------------+---------+-------------+--------+----------+----------------+
我有指标TotalofOne
,它是每个月显示的全年总数,然后,我有%OneTotalOne
,基本上是指标One
占总数的百分比。然后,我将度量Total2
划分为相应的百分比,因为80是每年的值,而我没有每月的数据(这就是为什么要划分它的原因)。现在,我将结果减去它的值%timeTotal2 - Three
,以便对其进行度量-表格计数,而我想对这一subtract
进行YTD的计算,如上一列所示。问题是当我使用TOTALYTD
时该度量为零。
Result =
VAR _TotalofOne = CALCULATE([One];ALLEXCEPT('Calendar';'Calendar'[Date].[Year]))
VAR _%OneTotalOne = DIVIDE([One];[TotalofOne];0)
VAR _Total2 = CALCULATE(TableX[ColumnX];ALLEXCEPT('Calendar';'Calendar'[Date].[Year]))
VAR _%timeTotal2 = _Total2*_%OneTotalOne
VAR _diff = _%timeTotal2-TableT[Three]
RETURN
TOTALYTD(_diff;DATESYTD(ALL('Calendar'[Date])))
此代码在一个代码中显示了度量,但是为了更好地理解,表中显示了作为度量创建时的每个变量。使用的所有表都与我的日期表有关。
谢谢。
编辑:
我不在乎%timeTotal2
和Three
都将是年初至今,然后两者都减去。