cancel
Showing results for 
Search instead for 
Did you mean: 
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
Microsoft
Microsoft

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
Microsoft
Microsoft

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

Steve_Wheeler
Solution Sage
Solution Sage

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
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Top Kudoed Authors