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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
evertontt
New Member

Temporal filters with 3 different periods. Example Google Analytics.

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;
power bi.JPG

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @evertontt ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1696835796881.png

CALENDAR = CALENDAR(DATE(2023,1,1),DATE(2023,12,31))

vtangjiemsft_1-1696835819830.png

(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.

vtangjiemsft_2-1696835952444.png

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. 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @evertontt ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1696835796881.png

CALENDAR = CALENDAR(DATE(2023,1,1),DATE(2023,12,31))

vtangjiemsft_1-1696835819830.png

(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.

vtangjiemsft_2-1696835952444.png

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. 

lbendlin
Super User
Super User

Use the Filter Pane, it has Advanced Filter options, including Relative Date.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.