I am going crazy trying to solve this puzzle: I need to calculate cumulative totals withing a giving period of time (Month Year Slicer). I have figure out this measure:
It works fine when the fact table have values for the specific MonthYear selected on the slicer. Problem is when fact table doesn’t have any value for than giving period of time. In this case, measures gives me back whole total instead of cumulative.
The measures are giving you back the total of whole time because the under the Filter part the condition is applied as “ALL” instead of “ALLSELECTED”. When we mention “ALL” it ignores the entire context and gives us the overall result inspite of selections made into the slicer/filter.
Can you give this formula a try as mentioned below -
First of all, thanks for your quick answer though it hasn’t worked. If I use ALLSELECTED it would give me back the result for the Month Year Selected on the slicer, not the cumulative value from the beggining of the year.
It is strange becouse I am using the same patterns in other fact tables and my original measure works fine. Also, when the measure is applied in a month with values it also works fine. It only does not work for those months that don’t have value…
hi, this YTD calculation you will need to have ALL at your VAR _firstdate, the purpose of using VAR is creating a new context outside the row context you’re currently on.
I’m not too fancy as dax on top of my head, but try this:
YTD Total PO Receipt Value USD =
VAR GetCurrentYear =
MAXX ( FILTER(Fiscal_Calendar,Fiscal_Calendar[FC Day Offset]<=0),Fiscal_Calendar[FC Year] )
VAR EndDate =
MAX(Fiscal_Calendar[Calendar Date])
VAR StartDate =
CALCULATE (
MINX (
FILTER ( ALL (Fiscal_Calendar), Fiscal_Calendar[FC Year] = GetCurrentYear ),
Fiscal_Calendar[Calendar Date]
)
)
RETURN
CALCULATE (
[Total PO Receipt Value USD],
Fiscal_Calendar[Calendar Date] >= StartDate,
Fiscal_Calendar[Calendar Date] <= EndDate
)