Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
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
Hello Community,
I would like to know if possible to convert this sql query to dax query.
here is the query:
SELECT * ,
Lag(User, 1,'') OVER( PARTITION BY id
ORDER BY Date ASC) AS UserTarget
FROM table
my table is:
| id | date | activity | target act | user | targetuser |
| 1 | 10-Oct | eat | drink | a | b |
| 1 | 10-Nov | drink | sleep | b | c |
| 1 | 12-Dec | sleep | xxxx | c | xxxx |
| 2 | 10-Oct | eat | dink | a | b |
| 2 | 10-Nov | drink | sleep | b | c |
| 2 | 12-Dec | sleep | xxxxx | c | xxxxx |
Solved! Go to Solution.
UserTarget =
MAXX(
TOPN(
1,
FILTER(
TBL,
TBL[id] = EARLIER( TBL[id] )
&& TBL[date] > EARLIER( TBL[date] )
),
TBL[date], ASC
),
TBL[user]
)
| 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! |
UserTarget =
MAXX(
TOPN(
1,
FILTER(
TBL,
TBL[id] = EARLIER( TBL[id] )
&& TBL[date] > EARLIER( TBL[date] )
),
TBL[date], ASC
),
TBL[user]
)
| 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! |
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 |
|---|---|
| 43 | |
| 37 | |
| 34 | |
| 21 | |
| 16 |
| User | Count |
|---|---|
| 65 | |
| 65 | |
| 30 | |
| 26 | |
| 25 |