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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
stuhoughton
Regular Visitor

Last 30 day vs Previous 30 day

Hey all,

Looking for some help in comparing the last 30 days to the previous 30 day period.

I've got an export of Google Search Console data which is loaded into one table.
I've summarised the date range 1/3/2022 - 30/3/2022 (last 30 days) into a table. 

stuhoughton_1-1649332430853.png

To highlight the DAX used to summarize the clicks, I used. 

 

last 30 day clicks = 
CALCULATE (
    SUM ( mytable[clicks] ),
    DATESINPERIOD ( date_lookup[date], MAX ( date_lookup[date] ), -30, DAY )
)

 

I then went through the same process to summerize total impressions, av pos and keyword count. 
What I'm struggling with is how to write the DAX which takes the previous 30 day period (30/1/2022 - 28/2/2022). 
Hope this makes sense as to what it is I'm trying to achieve. 

Thanks,

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@stuhoughton , Last 30 before 30

last 30 day before 30  clicks = 
CALCULATE (
    SUM ( mytable[clicks] ),
    DATESINPERIOD ( date_lookup[date], MAX ( date_lookup[date] ) -30 , -30, DAY )
)

 

make sure date_lookup is marked as date table

View solution in original post

2 REPLIES 2
stuhoughton
Regular Visitor

Hey @amitchandak thanks for the super quick response.

Yeah that works perfectly. I'm still learning the basics really appreicate your help. 😊

amitchandak
Super User
Super User

@stuhoughton , Last 30 before 30

last 30 day before 30  clicks = 
CALCULATE (
    SUM ( mytable[clicks] ),
    DATESINPERIOD ( date_lookup[date], MAX ( date_lookup[date] ) -30 , -30, DAY )
)

 

make sure date_lookup is marked as date table

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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