Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Gensetter
Frequent Visitor

Cumulative Total for selected period in prior year

I am running into issues with cumulative totals and was wondering if anyone else has solved this issue:

 

I am trying to create a chart which shows the cumulative total for the selected perioed, the target for the selected period, and the cumulative PY total for the selected period. I can get it all to work except for the PY cumulative total.

Here is a chart to illustrate my progress and problem.

image.png

The cumulative total that works (the green line) uses this DAX Expression:

Order Net YTD (G) =
VAR EndDate =
MAX ( DIM_DATE_TABLE[Date] )
VAR CumulativeTotalCY =
CALCULATE (
SUM ( SalesFact[Net Value] ),
FILTER (
ALLSELECTED ( DIM_DATE_TABLE ),
DIM_DATE_TABLE[Date] <= EndDate
)
)
RETURN
IF (
MAX ( DIM_DATE_TABLE[Date] ) <= [Date of Most Recent Data],
CumulativeTotalCY,
BLANK ()
)

And the little black squigly line at the bottom of the chart is the one that is broken. I can't get it to be a cumulative total of the prior year.

That dax expression is simply 

CALCULATE( [Order Net YTD (G)] , SAMEPERIODLASTYEAR(DIM_DATE_TABLE[Date]))

I'm not using the TotalYTD because the business requirement is the user is able to pick the start and end date.
The only filter applied to the page is Year = 2019.





1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi, @Gensetter 

For your case, you could use this formula to add a PY measure

Measure 3 = CALCULATE(CALCULATE( [Order Net YTD (G)] , SAMEPERIODLASTYEAR(DIM_DATE_TABLE[Date])),
FILTER (
ALLSELECTED ( DIM_DATE_TABLE ),
DIM_DATE_TABLE[Date] <= MAX(DIM_DATE_TABLE[Date])
))

Result:

2.JPG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-lili6-msft
Community Support
Community Support

hi, @Gensetter 

For your case, you could use this formula to add a PY measure

Measure 3 = CALCULATE(CALCULATE( [Order Net YTD (G)] , SAMEPERIODLASTYEAR(DIM_DATE_TABLE[Date])),
FILTER (
ALLSELECTED ( DIM_DATE_TABLE ),
DIM_DATE_TABLE[Date] <= MAX(DIM_DATE_TABLE[Date])
))

Result:

2.JPG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors