问题
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