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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register 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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.