Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
I have a "sales" table with team ID, payment type and date (see example below):
I want to write a DAX formula that will "lookup" the prior month's sales amount for a "Monthly" team and the 3 month prior sales amount for a "Quarterly" team. The lookup also needs to be filtered by team ID, so the prior sales belong to the same team.
Here's an example of the desired output (Change in Sales) :
PriorMonthSales =CALCULATE( SUM(Table[Sales]), FILTER( Table[TeamID]&& Table[Date] - 1 ) PriorQuarterSales =CALCULATE( SUM(Table[Sales]), FILTER( Table[TeamID]&& Table[Date] - 3 ) PriorSales = IF(Table[PaymentType] = "Monthly",PriorMonthSales, PriorQuarterSales)
These formulas obviously don't produce the desired result, but I am sharing them here to show my approach to solving this. Perhaps, someone more knowledgeable here can assist with the correct syntax and logic.
Thanks!
Hi @aeid101,
In your scenario, please follow steps below to calculate the difference for sales within each Team ID instance:
1. Return previous date within each Team ID group instance.

2. Return previous sales within each Team ID group instance.

3. Calculate teh difference between each row within each Team ID instance.

Reference:
PowerPivot DAX Session Notes 2 – Previous Row
If you have any question, please feel free to ask.
Best Regards,
Qiuyun Yu
Do you have a calendar table? It doesn't look like it. I suggest you read my article about calendar tables here.
http://exceleratorbi.com.au/power-pivot-calendar-tables/
It looks like a monthly calendar table will work for you. Make sure you have an ID column and then you can write your filter function to operate on the ID column.
Post back if that doesn't make sense
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 48 | |
| 40 | |
| 37 | |
| 20 | |
| 16 |
| User | Count |
|---|---|
| 69 | |
| 67 | |
| 32 | |
| 27 | |
| 26 |