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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pbi_twahyu
Regular 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
v-danhe-msft
Employee
Employee

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.