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

Last Sales N Months from Current Selection TOP Product

Below is the table I have :

Table.PNG

 

 

 

 

 

 

 

 

 

 

 

 

I have 2 slicers from calendar table :

1. Column Year

2. Column Month Name

 

I am trying to get Last 6 Months Sales from TOP 5 Product of Current Selection.

 

So If selected slicer is June & 2018

 

the expected result in my component (Matrix : Rows=ProductName, Columns=MonthYear, Values=UnitSold)

(taking only TOP 5 on June and get the last 6 months historical unit sold)

Expected Result.PNG

 

 

 

 

 

 

 

 

but what I have got is as following :

(it is taking TOP 5 on each month instead of taking only TOP 5 on June and get the last 6 months historical unit sold)

Result.PNG

 

 

 

 

 

 

 

 

 

 

 

 

based on this post, i create measure :

 

UnitSold_Last6Months =
VAR MinDate = VALUES('Calendar'[Start of Month])
VAR MaxDate = VALUES('Calendar'[End of Month])
RETURN
CALCULATE([UnitSold], DATESBETWEEN('Calendar'[Date], DATEADD(MinDate,-5,MONTH),MaxDate))

 

UnitSold =
VAR MinDate = MIN('Calendar'[Date])
VAR MaxDate = MAX('Calendar'[Date])
VAR TopRank =
CALCULATE([UnitSold_Last6Months], 
KEEPFILTERS(
CALCULATETABLE(
TOPN(10, ALLSELECTED(Product[ProductName]), [UnitSold_Last6Months]),
CALCULATETABLE('Calendar', 'Calendar'[Date]>= MinDate, 'Calendar'[Date]<= MaxDate, ALL(Product))
)
)
)

RETURN TopRank

 

I really appreciate for any help and suggestion 

 

Thank you

1 REPLY 1
Community Support Team
Community Support Team

Re: Last Sales N Months from Current Selection TOP Product

Hi @pbi_twahyu,

Could you please share your sample file to have a test if possible?

 

Regards,

Daniel He

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