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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to calculate a warranty end date based on the type of warranty using DAX?

I have two tables with the following column(s) 'Sales'[WarrantyStart] and this table with a grouped column 'Products'[WarrantyType] (string data type). I generally know how to add years to a date, just not sure how to go about putting this together since I just learned DAX a couple months ago: 

 

Date(year('Sales'[WarrantyStart])+3,month('Sales'[WarrantyStart]),day('Sales'[WarrantyStart]))

Warranty Type examples = 

Seven Year Extended Limited Warranty

Standard Limited Warranty

Five Year Limited Warranty

 

What is the best way to go about adding years to the [WarrantyStart] date based on the [WarrantyType]?? Thank you for any help!

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

For that you can use the SWITCH() statement.

 

 

Date(year('Sales'[WarrantyStart])+
SWITCH('Products'[WarrantyType]
  ,"Seven Year Extended Limited Warranty",7
  ,"Five Year Limited Warranty",5
  ,3)
,month('Sales'[WarrantyStart])
,day('Sales'[WarrantyStart]))

 

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

For that you can use the SWITCH() statement.

 

 

Date(year('Sales'[WarrantyStart])+
SWITCH('Products'[WarrantyType]
  ,"Seven Year Extended Limited Warranty",7
  ,"Five Year Limited Warranty",5
  ,3)
,month('Sales'[WarrantyStart])
,day('Sales'[WarrantyStart]))

 

Anonymous
Not applicable

I used this exact code, only thing I did different was add the 'Products'[WarrantyType] column to the 'Sales' table using the following code:

wType =
CALCULATE(
FIRSTNONBLANK('Products'[WarrantyType], TRUE()),
Filter('Products', [ProductID] = [SalesProductID]
))

This version should also work

 

wType =
CALCULATE(
FIRSTNONBLANK('Products'[WarrantyType], TRUE()),
[ProductID] = [SalesProductID]
)

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors