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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
deevs
Helper III
Helper III

Show last 30 days data in a chart

I need to show lastest 30 days data in the chart below based on the slicer selection. chart should only show last 30 days.
For an example if you only select 2019 chart should show the latest month’s 30 days. same applies to Quarter or if a month selected.

Any help is greatly appreciated.

 

image.png

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @deevs ,

 

We can create a date table and a measure to meet your requirement.

 

1. Create a date table that has no relationship with others.

 

Date = ADDCOLUMNS(CALENDAR("2020/1/1","2020/6/1"),"year",YEAR([Date]),"Quarter",QUARTER([Date]),"month",MONTH([Date]))

 

show1.jpg

 

2. Then we can use the date table to create four slicers.

 

show2.jpg

 

3. At last we can create a measure to get the result.

 

Measure = 
var _select_date = SELECTEDVALUE('Date'[Date])
var _select_date_30 = _select_date - 30
var _select_M = ENDOFMONTH('Date'[Date])
var _select_M_30 = _select_M -30
var _sum1 = CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[Date]<=_select_date && 'Table'[Date]>=_select_date_30))
var _sum2 = CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[Date]<=_select_M && 'Table'[Date]>=_select_M_30))
return
IF(
    HASONEFILTER('Date'[Date]),_sum1,_sum2)

 

show3.jpg

 

show4.jpg

 

show5.jpg

 

show6.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

View solution in original post

3 REPLIES 3
v-zhenbw-msft
Community Support
Community Support

Hi @deevs ,

 

We can create a date table and a measure to meet your requirement.

 

1. Create a date table that has no relationship with others.

 

Date = ADDCOLUMNS(CALENDAR("2020/1/1","2020/6/1"),"year",YEAR([Date]),"Quarter",QUARTER([Date]),"month",MONTH([Date]))

 

show1.jpg

 

2. Then we can use the date table to create four slicers.

 

show2.jpg

 

3. At last we can create a measure to get the result.

 

Measure = 
var _select_date = SELECTEDVALUE('Date'[Date])
var _select_date_30 = _select_date - 30
var _select_M = ENDOFMONTH('Date'[Date])
var _select_M_30 = _select_M -30
var _sum1 = CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[Date]<=_select_date && 'Table'[Date]>=_select_date_30))
var _sum2 = CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[Date]<=_select_M && 'Table'[Date]>=_select_M_30))
return
IF(
    HASONEFILTER('Date'[Date]),_sum1,_sum2)

 

show3.jpg

 

show4.jpg

 

show5.jpg

 

show6.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

Fowmy
Super User
Super User

@deevs 

Use can use a Time Intelligence function to achieve that, Check 

DATESBETWEEN 


https://docs.microsoft.com/en-us/dax/datesbetween-function-dax

 

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

I accept KUDOS 🙂

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

@deevs , refer this

https://www.youtube.com/watch?v=duMSovyosXE

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.