Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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!
Solved! Go to Solution.
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]))
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]))
I used this exact code, only thing I did different was add the 'Products'[WarrantyType] column to the 'Sales' table using the following code:
This version should also work
wType =
CALCULATE(
FIRSTNONBLANK('Products'[WarrantyType], TRUE()),
[ProductID] = [SalesProductID]
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
60 | |
32 | |
27 | |
22 | |
22 |
User | Count |
---|---|
63 | |
49 | |
28 | |
24 | |
19 |