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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How would I set a start date and end date?

I am doing a line chart visualization. My x-axis is a date field. I want to filter it so that the start date is 30 days ago and the end date is the current date. How would I do this in Power BI?

1 ACCEPTED SOLUTION
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Anonymous

 

In Power BI Desktop, we can't directly fix a range on X-axis in a chart visual. If your data is up to today, you may try Visual Level filter to limit the TOPN dates based on the DateKey.

 

66666.PNG

However, I think a better approach is creating a calculated table which keeps the latest 30 days data so that you just need to populate this 30 days table into your chart.

1. Add a calculated column in your source table for tagging if current rows is within in "latest 30 days"

 

If in latest 30 days = IF(DATEDIFF(Table[Date],TODAY(),DAY)>30,0,1)

2. Then create a calculated table basedd on this column.

 

 

Latest 30 Days Table = FILTER(table,Table[If in latest 30 days]=0)

Regards,

 

View solution in original post

2 REPLIES 2
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Anonymous

 

In Power BI Desktop, we can't directly fix a range on X-axis in a chart visual. If your data is up to today, you may try Visual Level filter to limit the TOPN dates based on the DateKey.

 

66666.PNG

However, I think a better approach is creating a calculated table which keeps the latest 30 days data so that you just need to populate this 30 days table into your chart.

1. Add a calculated column in your source table for tagging if current rows is within in "latest 30 days"

 

If in latest 30 days = IF(DATEDIFF(Table[Date],TODAY(),DAY)>30,0,1)

2. Then create a calculated table basedd on this column.

 

 

Latest 30 Days Table = FILTER(table,Table[If in latest 30 days]=0)

Regards,

 

Greg_Deckler
Community Champion
Community Champion

You could create a calculated column like this:

 

DaysAgo = TODAY() - [Date] * 1.

Then just add a visual, page or report filter where DaysAgo is < 31



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors