Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello everyone, I would like to create a temporal filter like Google Analytics, where it allows the user to select the period for comparison.
Example:
- Current data, compared to 7 days ago;
- Current Data, comparing to 30 days ago;
- Current data, compared to 60 days ago;
- Current data, compared to 90 days ago;
Solved! Go to Solution.
Hi @evertontt ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
CALENDAR = CALENDAR(DATE(2023,1,1),DATE(2023,12,31))
(2) We can create a slicer table.
SlicerData = DATATABLE (
"Slicer", STRING,
{
{ "7 days ago" },
{ "30 days ago" },
{ "60 days ago" },
{ "90 days ago"}
}
)
(3)We can create a measure.
Measure =
var _a=CALCULATE(SUM('Table'[Value]),FILTER(ALL('CALENDAR'),'CALENDAR'[Date]=MAX('CALENDAR'[Date])-7))
var _b=CALCULATE(SUM('Table'[Value]),FILTER(ALL('CALENDAR'),'CALENDAR'[Date]=MAX('CALENDAR'[Date])-30))
var _c=CALCULATE(SUM('Table'[Value]),FILTER(ALL('CALENDAR'),'CALENDAR'[Date]=MAX('CALENDAR'[Date])-60))
var _d=CALCULATE(SUM('Table'[Value]),FILTER(ALL('CALENDAR'),'CALENDAR'[Date]=MAX('CALENDAR'[Date])-90))
return
SWITCH(TRUE(),
SELECTEDVALUE('SlicerData'[Slicer])="7 days ago",_a,
SELECTEDVALUE('SlicerData'[Slicer])="30 days ago",_b,
SELECTEDVALUE('SlicerData'[Slicer])="60 days ago",_c,
SELECTEDVALUE('SlicerData'[Slicer])="90 days ago",_d,BLANK())
(4) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @evertontt ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
CALENDAR = CALENDAR(DATE(2023,1,1),DATE(2023,12,31))
(2) We can create a slicer table.
SlicerData = DATATABLE (
"Slicer", STRING,
{
{ "7 days ago" },
{ "30 days ago" },
{ "60 days ago" },
{ "90 days ago"}
}
)
(3)We can create a measure.
Measure =
var _a=CALCULATE(SUM('Table'[Value]),FILTER(ALL('CALENDAR'),'CALENDAR'[Date]=MAX('CALENDAR'[Date])-7))
var _b=CALCULATE(SUM('Table'[Value]),FILTER(ALL('CALENDAR'),'CALENDAR'[Date]=MAX('CALENDAR'[Date])-30))
var _c=CALCULATE(SUM('Table'[Value]),FILTER(ALL('CALENDAR'),'CALENDAR'[Date]=MAX('CALENDAR'[Date])-60))
var _d=CALCULATE(SUM('Table'[Value]),FILTER(ALL('CALENDAR'),'CALENDAR'[Date]=MAX('CALENDAR'[Date])-90))
return
SWITCH(TRUE(),
SELECTEDVALUE('SlicerData'[Slicer])="7 days ago",_a,
SELECTEDVALUE('SlicerData'[Slicer])="30 days ago",_b,
SELECTEDVALUE('SlicerData'[Slicer])="60 days ago",_c,
SELECTEDVALUE('SlicerData'[Slicer])="90 days ago",_d,BLANK())
(4) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Use the Filter Pane, it has Advanced Filter options, including Relative Date.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 6 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 16 | |
| 8 | |
| 7 | |
| 7 |