Forum Discussion
Compare products launch with user input launch date
Hi community
My objective is to compare sales for multiple products with each having different launch dates.
I want to be able to choose eg. 2 products and compare the sale of them by days after launch.
The problem is that the launch date has to be user input and not a calculated column.
The final result should be a graph as follows:
X-axis: Days after launch
Y-Axis: Qty
Legend: Product name
I have experimented with field parameters and making multiple measures for each slicer without succes.
The graph below should only contain the products from slicers "Product " 1 and 2.
The days after launch for each product should be calculated based on the "Launch date associated to product x"
Ultimately looking like this (Source: https://community.powerbi.com/t5/Desktop/Comparing-Product-Life-Cycle-of-different-products-Cumulatively/m-p/2839879)
But with the ability to choose products and launch date as in the first picture
I havent found any solutions in this community without a fixed product launch date.
I'm starting to think that it is not possible to do in Power BI.
I have attached a .pbix file
Any ideas are welcome and very appreciated!!!
Hi Anonymous ,
To do this you need to make the same thing you did for the slicers of the products, create 3 tables with the dates then change your measure to:
Product comparison = VAR FirstSold = CALCULATE ( MIN ( Sales[Sell_Date] ), Products[ProductName] IN { SELECTEDVALUE ( 'Product 1'[ProductName] ), SELECTEDVALUE ( 'Product 2'[ProductName] ), SELECTEDVALUE ( 'Product 3'[ProductName] ) } ) VAR SelectionFirstDate = SWITCH( MAX( Products[ProductName]), SELECTEDVALUE ( 'Product 1'[ProductName] ),MIN ( Product1Date[Date] ), SELECTEDVALUE ( 'Product 2'[ProductName] ),MIN ( Product2Date[Date] ), SELECTEDVALUE ( 'Product 3'[ProductName] ),MIN ( Product3Date[Date] ), FirstSold) VAR LastSold = CALCULATE ( MAX ( Sales[Sell_Date] ), Products[ProductName] IN { SELECTEDVALUE ( 'Product 1'[ProductName] ), SELECTEDVALUE ( 'Product 2'[ProductName] ), SELECTEDVALUE ( 'Product 3'[ProductName] ) } ) VAR days = SELECTEDVALUE ( 'Days after launch'[Days] ) RETURN CALCULATE ( Sales[Qty], FILTER ( ALL ( 'Date' ), 'Date'[Date] >= SelectionFirstDate + days && SelectionFirstDate + days <= LastSold ), FILTER ( Products, Products[ProductName] IN { SELECTEDVALUE ( 'Product 1'[ProductName] ), SELECTEDVALUE ( 'Product 2'[ProductName] ), SELECTEDVALUE ( 'Product 3'[ProductName] ) } ) )You can also adjust the formula to pick up the sales first day if nothing is selected on the filter, if you need help please reach out.
10 Replies
- MFelix
Super User
Hi Anonymous
Without data is difficult to pinpoint, but believe you need a specific metric.
Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.
If the information is sensitive please share it trough private message.- AnonymousNot applicable
Hi MFelix
Thank you for your reply.
Here is a link to a sample file that resembles my data model: https://we.tl/t-W32vBnJz2W
On page 2 i have tried creating a measure that "resets" sales dates to an x-axis of Days after launch.
Without any luck though.
Again the objective is to choose eg. 3 products, having the user set a launch date for each product, and then comparing sales from those dates as a function of days after launch.
Any help would be much appreciated!
- MFelix
Super User
Hi Anonymous
Believe that you have an error on your calculation you have the following:
FILTER ( ALL ( 'Date' ), 'Date'[Date] = FirstSold + days && FirstSold + days <= LastSold )Believe this should be:
FILTER ( ALL ( 'Date' ), 'Date'[Date] >= FirstSold + days && FirstSold + days <= LastSold )Final result is this:
Is this the result you pretend?