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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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