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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
domtrump
Helper II
Helper II

Activity before and after a date

I have customer records in a table with all sales activity. For each customer, there is a single trigger date for a particular event (when they became a loyalty member). Every customer's trigger date will be different. I'm looking for a pattern that will summarize the patrons sales data for the six months prior to the trigger date (and then I'll use the same pattern to get the six months after for comparison). How do I go about this?

1 REPLY 1
FreemanZ
Super User
Super User

hi @domtrump 

try like:

Diff = 
VAR _triggerdate =
VAR _currentdate = MAX(TableName[Date])
VAR _salespre =
CALCULATE(
    SUM(TableName[Sales]),
    TableName[Date] >= EDATE(_currentdate, -6),
    TableName[Date] <= _currentdate
)
VAR _salesafter =
CALCULATE(
    SUM(TableName[Sales]),
    TableName[Date] <= EDATE(_currentdate, 6),
    TableName[Date] >= _currentdate
)
RETURN
_salesafter - _salespre

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.