Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Dear all,
Could anyone help me with the formula? I tried to use the following formula to access the previous row (second to last date) in a virtual table but it didn't work as expected.
VAR Product1 =
SELECTEDVALUE ( 'Product Master'[ProductKey] )
VAR Customer1 =
SELECTEDVALUE ( 'Customer Master'[CustomerKey] )
VAR Table1 =
SUMMARIZECOLUMNS (
'Sales Date'[Date],
'Customer Master'[Customer Name],
'Product Master'[Product Name],
"Sales", [Total Net Sales]
)
VAR SalesLastDate =
CALCULATE (
LASTDATE ( 'Sales Date'[Date] ),
'Sales Fact'[ProductKey] = Product1,
'Sales Fact'[CustomerKey] = Customer1
)
RETURN
ADDCOLUMNS (
Table1,
"LastOrderDate",
CALCULATE (
CALCULATE (
LASTDATE ( 'Sales Date'[Date] ),
FILTER ( 'Sales Date', 'Sales Date'[Date] <> saleslastdate )
),
'Sales Fact'[ProductKey] = Product1,
'Sales Fact'[CustomerKey] = Customer1
)
)
Could DAX let us access the previous row (Like using earlier or Var. in a calculated column?)
Here is my result
My objective is to averagex the result of datediff between date and lastorderdate in a virtual table format.
(To get average order date duration for each product & each customer)
Thank you in advance for your advices.
@DaxNewbies ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 9 | |
| 9 | |
| 8 | |
| 6 | |
| 6 |
| User | Count |
|---|---|
| 21 | |
| 20 | |
| 20 | |
| 14 | |
| 14 |