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
sfong002
New Member

Show previous 6 months, dynamic

Hello,

 

New to Power BI, so I wanted to know if there is a way to dynamically create a line chart showing the past 6 months of my data.

In my data I have a "month_year" column, and to retrieve the current month everytime, so that I don't have to filter into the new date, I created a measure 

Max Month = CALCULATE(max(Table1[month_year]), all(Table1)) and then created a new column

Latest = if(Table1[month_year]=[Max Month],"Curent Month","")

 

Now I can show the last 6 months easily by creating a hierarchy with month_year and filtering in the 6 month dates, but is there a formula I can use to dynamically display the last 6 months

 

data is suppose to just show the revenue growth for 6 months 

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

Hi @sfong002,

In your scenario, you can create a calculated column using the following formula, then use the column in slicer. For more details, you can check the screenshots below.

Date Periods = 
VAR Datediff =
1
* ( Table1[Date] - TODAY () )
RETURN
SWITCH (
TRUE,
AND ( Datediff <= 0,Datediff >= -180 ), "Last 6 Months",
Datediff < 180, "Older than 6 Months"
)




1.PNG2.PNG



Thanks,
Lydia Zhang

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

View solution in original post

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

Hi @sfong002,

In your scenario, you can create a calculated column using the following formula, then use the column in slicer. For more details, you can check the screenshots below.

Date Periods = 
VAR Datediff =
1
* ( Table1[Date] - TODAY () )
RETURN
SWITCH (
TRUE,
AND ( Datediff <= 0,Datediff >= -180 ), "Last 6 Months",
Datediff < 180, "Older than 6 Months"
)




1.PNG2.PNG



Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

If you only need the last 6 months' data anywhere in your report, you can filter the data when you get it, via

  • Edit Query,
  • Click the filter drop-down on your date column, 
  • Click Date Filters > In the Previous...

If you need that filter applied to just one visual in your report, you may need some more dynamic filtering such as that described by Chris Webb at Building Relative Date Reports in PowerPivot

 

 

 

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.