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
Drake023
Regular Visitor

Change of dates with slicer selection

Hi Guys,

 

Here is my problem.

I have a line graph with last 6 months data which is default, now when I select July automaticall the line graph should show past 6 months from July, simillary if I select May the graph automatically move to 6 months past from may. I should not consider the month I selected in the graph only the past 6 months from the month I selected.

 

 

Thanks in advance.

3 REPLIES 3
Fowmy
Super User
Super User

@Drake023 

Make a copy of your dates table and don't create any relationship to it, make sure your have Month-Year Column, you create like 

Month Year = FORMAT('DATE'[Date], "Mmm YYYY")

 
Place that Month Year Field on a slicer for the user to choose, create the measure as

 

Past 6 Months = 
VAR _D = EDATE(MIN('Dates2'[Date]),-6) return
IF( 
    MAX('DATE'[Date]) < _D ||  MAX('DATE'[Date]) > MIN('Dates2'[Date]),
    BLANK(),
    [Total Sales]
)

 


I selected Jan 2017, the chart shows the past 6 months

 

Screenshot 2020-09-23 113902.png

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

amitchandak
Super User
Super User

@Drake023 , Create a column like this in you date table and use that as filter

 

Month Type = Switch( True(),
eomonth([Date],0) <= eomonth(Today(),0) && eomonth([Date],0) >= eomonth(Today(),-6),"Last 6 Month" ,
Format([Date],"MMM-YYYY")
)

 This may not work as today is considered.I want last 6 months based on user selection year and month.

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.