Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hey,
I need help in creating below DAX.
We need to calculate the transaction gap between all transactions for each customer. The maximum transactions gap is the longest a customer has gone between transactions.
For this I have written below DAX, but the problem here is I am not able to find max and average value as its getting sum up.
Also, transaction Gap should exculde weekends.
Transaction Gap =
var current_date = SELECTEDVALUE(data[Invoice Date])
var previous_invoice_date =
CALCULATE(
MAX(data[Invoice Date]),
FILTER(
ALLEXCEPT(data,data[Customer Name],data[Product]),
data[Invoice Date] < current_date
)
)
var diff =
CALCULATE(
COUNTROWS('Date'),
DATESBETWEEN('Date'[Date],previous_invoice_date,current_date),
'Date'[IsWeekend] = FALSE(),
ALL(data)
)
RETURN diff
Solved! Go to Solution.
For fun only, Excel worksheet formulas are powerful enough,
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
For fun only, Excel worksheet formulas are powerful enough,
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
You could create a measure like
Max gap =
var summaryTable = ADDCOLUMNS( SUMMARIZE( 'data', 'data'[Customer Name], 'data'[Product]),
"@val", [Transaction Gap])
return MAXX( summaryTable, [@val])You can do the same with AVERAGEX
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 24 | |
| 12 | |
| 11 | |
| 9 | |
| 8 |