cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
awitt Regular Visitor
Regular Visitor

Aged product YOY comparison

I have a sales table and a seperate products table that are related and i'm looking to create a column within the sales table that identifies the age of that product at the time of the sale. 

 

For example if I sold a 2018 copyright product today, this column would spit out "1 year" or something of the like. However if I sold that exact same product in 2018 it would have been a "new" product at that time. I am then going to compare 1 year old product sales from 2018 to 1 year old product sales this year (and 2 year, 3 year, etc. ). 

 

I have a copyright column for each product in my products table that tells me the copyright year and my sales table has an order date per product sale so it should be fairly straight forward to compare the dates (they are in different date formats - year vs date/time). 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Aged product YOY comparison

hi, @awitt 

You could use DATEDIFF to create a IF conditional column in Sales table.

For example:

column = If( DATEDIFF([SalesDate], [copyright Date],Year) =0,"new"If( DATEDIFF([SalesDate], [copyright Date],Year) =1, "1 year"   ......

 

If you still need help, please share some sample data and expected output.

 

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Aged product YOY comparison

hi, @awitt 

You could use DATEDIFF to create a IF conditional column in Sales table.

For example:

column = If( DATEDIFF([SalesDate], [copyright Date],Year) =0,"new"If( DATEDIFF([SalesDate], [copyright Date],Year) =1, "1 year"   ......

 

If you still need help, please share some sample data and expected output.

 

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

awitt Regular Visitor
Regular Visitor

Re: Aged product YOY comparison

Marking this as solved with 1 minor change in the code. Since I am looking at past copyright dates, instead of the DATEDIFF = 1 for 1 year old copyrights, I changed it to the DATEDIFF equation = -1 and that seemed to work.

 

Thanks for your help! 

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors
Top Kudoed Authors