Forum Discussion
Cumulative Calculation to Date
- 5 years ago
Anonymous ,
I can see what you were doing, working with only variables, but unfortunately It produced the same thing that my previous formula did. However, you did set me on track for what I was looking for. I had to replace the ALL(TIME[Entry Date]) with ALLCROSSFILTERED(TIME[Entry Date]), because the ALL was still enforcing the filtering coming from the outside table. ALLCROSSFILTERED got rid of those filters coming from the table where I keep my Time Entry Categories. So my final formula wound up being:
Cumulative Cost by Day = VAR LastDate1 = CALCULATE(LASTDATE('TIME'[EntryDate]),ALLCROSSFILTERED('TIME')) RETURN IF( SELECTEDVALUE('Calendar Table'[Date])> LastDate1, BLANK(), CALCULATE( SUM('TIME'[COST]), FILTER(ALLSELECTED('Calendar Table'[Date]), 'Calendar Table'[Date] <= MAX('Calendar Table'[Date]) ) ) )Thank you for your time and reply.
What about this?
[Cumulative Hours by Day] =
// this returns the very last
// date that exists in the
// fact table TIME regardless
// of any selections made
VAR __lastDateWithData =
CALCULATE(
MAX('TIME'[EntryDate]),
ALL('TIME')
)
var __currentDate =
SELECTEDVALUE(
'Calendar Table'[Date],
// +1 in order for this to
// work in the IF condition
__lastDateWithData + 1
)
var __result =
IF(
and(
HASONEFILTER( 'Calendar Table'[Date] )
__currentDate <= __lastDateWithData
),
CALCULATE(
SUM( 'TIME'[Duration] ),
'Calendar Table'[Date] <= __currentDate,
ALLSELECTED('Calendar Table')
)
)
return
__result- Caz_165 years ago
Helper II
Anonymous ,
I can see what you were doing, working with only variables, but unfortunately It produced the same thing that my previous formula did. However, you did set me on track for what I was looking for. I had to replace the ALL(TIME[Entry Date]) with ALLCROSSFILTERED(TIME[Entry Date]), because the ALL was still enforcing the filtering coming from the outside table. ALLCROSSFILTERED got rid of those filters coming from the table where I keep my Time Entry Categories. So my final formula wound up being:
Cumulative Cost by Day = VAR LastDate1 = CALCULATE(LASTDATE('TIME'[EntryDate]),ALLCROSSFILTERED('TIME')) RETURN IF( SELECTEDVALUE('Calendar Table'[Date])> LastDate1, BLANK(), CALCULATE( SUM('TIME'[COST]), FILTER(ALLSELECTED('Calendar Table'[Date]), 'Calendar Table'[Date] <= MAX('Calendar Table'[Date]) ) ) )Thank you for your time and reply.
- Anonymous5 years agoNot applicableIf removing all filters with ALL does not work, it means somewhere in your code you must have a bidirectional filter(s) enabled. Is this correct? If not, would you please care to explain why ALL did not work whereas ALLCROSSFILTERED did? Thanks.
- Caz_165 years ago
Helper II
Anonymous
Yes I have Bidirectional filters enabled for the Calendar table that Im trying to filter. ALLCROSSFILTERED removes all of the filters which are being applied across both tables, which results in the measure evaluating the measure for all of the rows in CalendarTable[Date], and not the rows specific to my Time Entry Category. See the documentation on ALLCROSSFILTERED for a good example.
https://docs.microsoft.com/en-us/dax/allcrossfiltered-function-dax
Caz