Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi All,
In my report i have a refresh date column which will have list of dates at which refresh happened. initially i want to show data for only latest 30 days to user. foe ex- if latest refresh date is 12/05/2020, data should be from 12/04/2020 to 12/05/2020.
I will have this refresh date column as slicer . whenever user clicks on particular date in this slicer, i should get data for 30 days from date of selection(if user clicks feb15, data should be from feb15-Mar14) and in other slicer i should get only dates between selected date and 30 days date(feb15-mar14 dates)( This slicer is for if user want to see single day data).
Please help me to solve this.
TIA
Solved! Go to Solution.
@Anonymous
Based on your description, I created data to reproduce your scenario.
Table:
DateTable:
DateTable = DISTINCT('Table'[Refresh Date])
You may create two measures as below.
Isdisplay =
var _date = SELECTEDVALUE('Table'[Refresh Date])
var _latestdate =
CALCULATE(
MAX('Table'[Refresh Date]),
ALL('Table')
)
return
IF(
DATEDIFF(_date,_latestdate,DAY)<=31,
1,
0
)
Visual control =
var _selecteddate = SELECTEDVALUE(DateTable[Refresh Date])
var _refreshdate = SELECTEDVALUE('Table'[Refresh Date])
return
IF(
ISFILTERED(DateTable[Refresh Date]),
IF(
DATEDIFF(_selecteddate,_refreshdate,DAY)<=31&&
DATEDIFF(_selecteddate,_refreshdate,DAY)>0,
1,
0
),
1
)
You need to put the measure in the visual level filter to display the result. 'Isdisplay' measure is to show data for only latest 30 days. 'Visual control' is to get data for 30 days from date of selection. Then you may use the 'Refresh Date' from DateTable to filter the visual with 'Visual Control'.
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous
Based on your description, I created data to reproduce your scenario.
Table:
DateTable:
DateTable = DISTINCT('Table'[Refresh Date])
You may create two measures as below.
Isdisplay =
var _date = SELECTEDVALUE('Table'[Refresh Date])
var _latestdate =
CALCULATE(
MAX('Table'[Refresh Date]),
ALL('Table')
)
return
IF(
DATEDIFF(_date,_latestdate,DAY)<=31,
1,
0
)
Visual control =
var _selecteddate = SELECTEDVALUE(DateTable[Refresh Date])
var _refreshdate = SELECTEDVALUE('Table'[Refresh Date])
return
IF(
ISFILTERED(DateTable[Refresh Date]),
IF(
DATEDIFF(_selecteddate,_refreshdate,DAY)<=31&&
DATEDIFF(_selecteddate,_refreshdate,DAY)>0,
1,
0
),
1
)
You need to put the measure in the visual level filter to display the result. 'Isdisplay' measure is to show data for only latest 30 days. 'Visual control' is to get data for 30 days from date of selection. Then you may use the 'Refresh Date' from DateTable to filter the visual with 'Visual Control'.
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Here is another example (attached)
Can you please explain what your logic is doing here. I mean how your power BI file explains my requirment
You would need something like a Complex Selector. See attached.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
80 | |
79 | |
59 | |
36 | |
35 |
User | Count |
---|---|
99 | |
57 | |
56 | |
46 | |
40 |