Forum Discussion
NitaDC
5 months agoRegular Visitor
Calculate YoY change
I have a date table with dates in the format mm/dd/yyyy and claims table with 'claimID' and service_Date(Values for 2023 and 2024). I want to create and card showing 2024 total claims count with %change. What is the efficient way to calculate, DAX measure or Python?
Thanks in Advance.
~Nita
Add a Year slicer from your Date table, select 2024, the measures respond to it automatically.
Total Claims = COUNTROWS ( 'claims' )Claims LY = CALCULATE ( [Total Claims], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )Claims YoY % = VAR _CurrentYear = [Total Claims] VAR _LastYear = [Claims LY] RETURN DIVIDE ( _CurrentYear - _LastYear, _LastYear )But keep it mind that:
- Your Date table must be marked as a Date Table (Table tools → Mark as date table)
- claims[service_Date] must be connected to Date[Date] via an active relationship
2 Replies
- NitaDCRegular Visitor
Thank you so much, I was not thinking of using the filter 😀
- cengizhanarslan
Super User
Add a Year slicer from your Date table, select 2024, the measures respond to it automatically.
Total Claims = COUNTROWS ( 'claims' )Claims LY = CALCULATE ( [Total Claims], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )Claims YoY % = VAR _CurrentYear = [Total Claims] VAR _LastYear = [Claims LY] RETURN DIVIDE ( _CurrentYear - _LastYear, _LastYear )But keep it mind that:
- Your Date table must be marked as a Date Table (Table tools → Mark as date table)
- claims[service_Date] must be connected to Date[Date] via an active relationship