英文:
Power Pivot - Get previous Year sum
问题
我有一个包含以下列标题的表格:
DeptName - ActualFees - Month - Year
我想在聊天中根据一个切片器选择年份(包括前一年),显示DeptName和金额。我尝试了几个代码,但都没有成功。年份列不是日期格式。
我已经尝试过:
SUMX (Table, Table[Year]=Table[Year]-1)
Calculate( Sum(Table[ActualFee], Table[Year]=Table[Year]-1)
SUMX( Filter(Table,
Table[Year] = Table[Year]-1,
Table[ActualFees])
英文:
I have a table with these headers:
DeptName - ActualFees - Month - Year
I want to see in a chat the Deptname and the amount, according to a slicer to select the year, plus the previous year. I have tried a few codes but none worked. The Year column is not in a date format.
I already tried:
SUMX (Table, Table[Year]=Table[Year]-1
Calculate( Sum(Table[ActualFee], Table[Year]=Table[Year]-1)
SUMX( Filter(Table,
Table[Year] = Table[Year]-1,
Table[ActualFees])
答案1
得分: 1
你可以使用类似以下的代码:
=VAR thisYear = VALUES(Table1[Year])
RETURN
IF(HASONEVALUE(Table1[Year]),CALCULATE(SUM([ActualFees]),ALL(Table1[YEAR]),Table1[Year]=thisYear-1),blank())
英文:
You could use something like:
=VAR thisYear = VALUES(Table1[Year])
RETURN
IF(HASONEVALUE(Table1[Year]),CALCULATE(SUM([ActualFees]),ALL(Table1[YEAR]),Table1[Year]=thisYear-1),blank())
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论