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
abc_777
Post Prodigy
Post Prodigy

last 6 months sale by select month from slicer

hi,

 

how to calculate the previous 6 months' sale by selecting a month from the slicer.

 

if I select November then the visual will show June to November sale

if I select august then the visual will show march to august sale

 

thanks

1 ACCEPTED SOLUTION

Sorry, it is my mistake. actually i am considering the end of month for the start date and didnt consider the entire month. for eg. if i select Sep-2021 it takes the 30-Apr-2021 as a start date but it should be 01-Apr-2021.

 

So, can you please correct the Start_Date measure as below,

 

Start_Date =
var MonthEnd = EOMONTH(MAX('Date Dim1'[Date]),-5)
return DATE(YEAR(MonthEnd),MONTH(MonthEnd),1)

View solution in original post

27 REPLIES 27

Hi,

 

If you dont select any month then it will take the very recent month automatically and give you the last 6 months data from the recent month

 

If you select Dec month then it will give you last 6 months data from Dec

v-jayw-msft
Community Support
Community Support

Hi @abc_777 ,

 

Create an independent slicer table as below.

month = DISTINCT('Table'[date].[MonthNo])

 Then create a measure and add it to visual filter.

Measure = 
var _month = month(SELECTEDVALUE('Table'[date]))
var _slicer = SELECTEDVALUE('month'[MonthNo])
return
IF(_month<=_slicer&&_month>=_slicer-5,1,0)

1.PNG2.PNG

 

Best Regards,

Jay

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

hi thanks for reply

 

here I have create but there is something wrong please help

 

Measure =
var _month = month(SELECTEDVALUE(BMCalendar[Date]))
var _slicer = SELECTEDVALUE('month'[MonthNo])
return
IF(_month<=_slicer&&_month>=_slicer-5,1,0)
 
6 months.jpg

Hi @abc_777 ,

 

May I ask where is the problem? In the screenshot you have selected July in the slicer so the value from February to July is 1. Do you want each month only appear once in the visual?

If so, you could modify the measure as below:

Measure = 
var _month = SELECTEDVALUE('Table'[date].[MonthNo])
var _slicer = SELECTEDVALUE('month'[MonthNo])
return
IF(_month<=_slicer&&_month>=_slicer-5,1,0)

Then use month hierarchy in the visual.

The result before applying the filter:

Capture.PNG

 

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@abc_777 , You need an independent date table for that

 

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

hi @amitchandak ,

 

I have tried the youtube link you gave. thanks for that but really unlucky. if you could help me out. 

hi, 

does anyone have any suggestions? not last 6 months but I will select say july then from july previous 6 months

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.