Forum Discussion
SAMEPERIODLASTYEAR returning blank / 0
I'm creating a calculated table in DAX and trying to come up with a total credits for last year measure. The strange thing is this was a dashboard I created in 2017 and didn't refresh until recently. Upon trying to refresh there were issues and I had to rebuild the dashboard but I took great care to recreate the same relationships and tables. This calculation was working before and isn't now. Further, I have other calculations using SAMEPERIODLASTYEAR that work just fine but they do reference other tables.
I did go in and mark the dates table as a date table as I saw that might be the issue but it didn't resolve anything. I've tried so many different things with this and nothing is resolving it. Any ideas? Unfortunately this is sensitive data I can't post the file.
Another odd thing about this is that I can compute this as a measure in the Course Information table with no issues. When I try to compute it as a column in that table it gives me a circular error - and I'm not sure that would work anyway because it seems I have to compute each of these metrics for the calculated table to return results correctly (I need this table because I'm using the Power KPI matrix which has to have everything summarized to return results the way I want them).
1 Reply
- AnonymousNot applicable
Hi ahumke ,
Please try to update the formula of your calculated table CourseEnrollmentTotals as below, the part with red font is new added:
CourseEnrollmentTotals =
SUMMARIZE (
'Course Information',
[Area],
[Program Title],
'Dates'[JanuaryDate],
"Credit Hours", SUM ( 'Course Information'[Program Credit Hours] ) + 0,
"TotalCreditHoursCountLY",
CALCULATE (
SUM ( 'Course Information'[Program Credit Hours] ) + 0,
SAMEPERIODLASTYEAR ( 'Dates'[Date] ),
ALL ( 'Dates' )
),
"DiffTYLYCreditHours",
IF (
ISBLANK ( [TotalCreditHoursCountLY] ),
BLANK (),
(
SUM ( 'Course Information'[Program Credit Hours] ) - [TotalCreditHoursCountLY]
)
),
"YOYChangeCreditHours",
IF (
[TotalCreditHoursCountLY] = 0,
0,
( DIVIDE ( [Diff. TY and LY Credit Hours], [TotalCreditHoursCountLY] ) )
),
"Completion Count", ( 'Course Information'[Completion Count] ),
"CompletionLY",
CALCULATE (
( 'Course Information'[Completion Count] ),
SAMEPERIODLASTYEAR ( 'Dates'[Date] )
),
"DiffTYLYCompletion",
IF (
ISBLANK ( [TotalCompletionCountLY] ),
BLANK (),
( SUM ( 'Course Information'[Completion.Count] ) - [TotalCompletionCountLY] )
),
"YOYChangeCompletion",
(
IF (
( [TotalCompletionCountLY] = 0 ),
0,
( [Diff. TY and LY Completion Count] / [TotalCompletionCountLY] )
)
),
"YOYSatisfactory", 'Course Information'[YOYSatisfactory],
"PrefixTotalHours", SUM ( 'All Course Credits Grouped'[Credit Hours for Prefix] ) + 0,
"PrefixCreditHoursLYg",
CALCULATE (
SUM ( 'All Course Credits Grouped'[Credit Hours for Prefix] ) + 0,
SAMEPERIODLASTYEAR ( 'Dates'[Date] )
),
"PrefixCreditHoursDiffg",
IF (
ISBLANK ( [PrefixCreditHoursLYg] ),
BLANK (),
( 'All Course Credits Grouped'[PrefixTotalHoursg] ) - [PrefixCreditHoursLYg]
),
"YOYChangePrefixCHg",
IF (
[PrefixCreditHoursLY] = 0,
0,
( DIVIDE ( [Diff. TY and LY Prefix Credit Hours], [PrefixCreditHoursLY] ) )
),
"Average Instructional Cost", CALCULATE ( AVERAGE ( 'STDandAverageTable'[Ave Inst. Cost] ) ),
"STDInstructCost", CALCULATE ( AVERAGE ( 'STDandAverageTable'[STDInstructionalCost] ) ),
"NetRevSatisfactory", 'Expense'[NetRevSatisfactory],
"Fill Rate Satisfied", 'Course Information'[FillRateSatisfied],
"SuccessRateSatisfactory", 'Course Information'[SuccessRateSatisfactory],
"Completion Target", 'Course Information'[Completion Target],
"TransferSuccess", 'Transfer by Program'[TransferSuccess],
"AccredSat", 'Course Information'[AccredSat],
"Instructional Cost Satisfactory", CALCULATE ( AVERAGE ( 'STDandAverageTable'[Ave Inst. Cost] ) ),
"Course Success",
CALCULATE (
(
SUM ( 'Course Information'[Program Success Grade] )
/ ( SUM ( 'Course Information'[Program Seat Count] ) )
)
),
"SuccessRateNeedsAttn", ( CALCULATE ( 'Course Information'[SuccessRateSatisfactory] - .05 ) )
)If the above one is not working for your scenario, please check the solution in the following similar threads. Hope they can help you resolve the problem.
SUMMARIZE function and SAMEPERIODLASTYEAR returning BLANK
SAMEPERIODLASTYEAR encapsulated into a SUMX/SUMMARIZE
Best Regards