Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
Solved! Go to Solution.
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]))
2. Then we can use the date table to create four slicers.
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)
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.
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]))
2. Then we can use the date table to create four slicers.
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)
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.
@deevs
Use can use a Time Intelligence function to achieve that, Check
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 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 36 | |
| 31 | |
| 28 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |