Need to default to last nonblank value

我的未来我决定 提交于 2019-12-24 20:45:46

问题


At present that dax calculation is a simple SUM, but I need to default to the last non-blank value for the GrandTotal:

For example, instead of stating 167, it should not 9:


回答1:


Similar to the other question you asked, you can use HASONEVALUE to change the behavior of the Grand Total. If the column you are summing is named Table1[Value] then the measure you want will look something like this:

LastNonBlankValue = 
    VAR LastNonBlankDate = CALCULATE(MAX(DimDate[Date]), Table1[Value] > 0)
    RETURN IF(HASONEVALUE(DimDate[Date],
               SUM(Table1[Value]),
               CALCULATE(SUM(Table1[Value]),
                         ALLSELCTED(DimDate[Date]),
                         DimDate[Date] = LastNonBlankDate))

This is intended to find the last non-blank date, and sum over just that date for the Grand Total.

Since I don't know your table and column names or context, you'll need to modify this to suit your particular situation, but it should give you an idea of what to try.



来源:https://stackoverflow.com/questions/48118392/need-to-default-to-last-nonblank-value

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