DAX Average Issue

ぃ、小莉子 提交于 2019-12-02 14:28:04

问题


I have this table

and this is the measurement i have to calculate the average

Traded Contract(MTD) := TOTALMTD(SUM([Traded Contract]), 'TestTable'([Trading Date]))

Average := [Traded Contract(MTD)]/SUM([Trading Days])

Currently the result of average is correct up to daily level, When I wish to see the monthly average, I didn’t filter by date, then I will get the result 9000/14 = 642 which is incorrect, I wish to see 4425 which is the total of each average. How do I amend my Average measurement query to get the expected result


回答1:


I'm not entirely sure why you would want to do this since 4425 isn't really an average, but you can write your formula as follows:

Average = SUMX(VALUES(TestTable[Trading Date]),
               [Traded Contract(MTD)] /
               LOOKUPVALUE(TestTable[Trading Days],
                           TestTable[Trading Date],[Trading Date]))

For more information on how these sort of measures work, I suggest reading the following article: Subtotals and Grand Totals That Add Up “Correctly”



来源:https://stackoverflow.com/questions/49150526/dax-average-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!