Forum Discussion
LiamReidy
Helper I
6 years agoForecast vs Actual Line Graph for current week or month
Hi Community! I have set targets for calories consumed on a daily basis over the course of a week/month. I want to view this as a cumulative line graph against the actual amount of calories i hav...
- Anonymous6 years ago
HI LiamReidy,
#1, You can use the following measure formulas to calculate rolling WTD actual or target based on date field:
WTD Acutal = VAR currDate = MAX ( Test[Date] ) RETURN CALCULATE ( SUM ( Test[Calorie Acutal] ), FILTER ( ALLSELECTED ( Test ), YEAR ( [Date] ) = YEAR ( currDate ) && WEEKNUM ( [Date], 2 ) = WEEKNUM ( currDate, 2 ) && [Date] <= currDate ) ) WTD Target = VAR currDate = MAX ( Test[Date] ) RETURN CALCULATE ( SUM ( Test[Calorie Target] ), FILTER ( ALLSELECTED ( Test ), YEAR ( [Date] ) = YEAR ( currDate ) && WEEKNUM ( [Date], 2 ) = WEEKNUM ( currDate, 2 ) && [Date] <= currDate ) )#2, I think you need to create a new table with date field which not has a relationship to current table records, then you can use it as the source field on slicer to interact new measures formulas:
Selected PWTD Target = VAR currDate = MAX ( Selector[Date] ) VAR prevWeekEnd = currDate - WEEKDAY ( currDate, 2 ) RETURN CALCULATE ( SUM ( Test[Calorie Target] ), FILTER ( ALLSELECTED ( Test ), YEAR ( [Date] ) = YEAR ( prevWeekEnd ) && WEEKNUM ( [Date], 2 ) = WEEKNUM ( prevWeekEnd, 2 ) && [Date] <= prevWeekEnd ) ) Selected WTD Actual= VAR currDate = MAX ( Selector[Date] ) RETURN CALCULATE ( SUM ( Test[Calorie Actual] ), FILTER ( ALLSELECTED ( Test ), YEAR ( [Date] ) = YEAR ( currDate ) && WEEKNUM ( [Date], 2 ) = WEEKNUM ( currDate, 2 ) && [Date] <= currDate ) )Regards,
Xiaoxin Sheng
LiamReidy
Helper I
6 years agoamitchandak Anonymous Thank you both! i will try both your suggestions and feedback to you later on 🙂