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 moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
I'm trying to write a dax expression which will give me a new column for my table "meetings".
It's suppose to fetch the meeting type for the next meeting for the client.
Current table:
| ID | CustomerID | Date | Type |
| 1 | 1 | 2023-02-01 | Startup |
| 2 | 2 | 2023-02-01 | Retention |
| 3 | 3 | 2023-02-01 | Startup |
| 4 | 2 | 2023-02-05 | Support |
| 5 | 1 | 2023-02-05 | Adjustment |
What I'm looking for:
| ID | CustomerID | Date | Type | Next meeting type |
| 1 | 1 | 2023-02-01 | Startup | Adjustment |
| 2 | 2 | 2023-02-01 | Retention | Support |
| 3 | 3 | 2023-02-01 | Startup | |
| 4 | 2 | 2023-02-05 | Support | |
| 5 | 1 | 2023-02-05 | Adjustment |
@sumsar10171 with new DAX OFFSET; PFA
Measure =
CALCULATE (
[__type],
OFFSET (
1,
DISTINCT ( ALL ( tbl ) ),
ORDERBY ( tbl[Date], ASC ),
KEEP,
PARTITIONBY ( tbl[CustomerID] )
)
)
Is it possible to write this as a column?
hi @sumsar10171
try like:
Column =
MINX(
TOPN(
1,
FILTER(
TableName,
TableName[CustomerID] = EARLIER(TableName[CustomerID])
&&TableName[Date] > EARLIER(TableName[Date])
),
TableName[Date],
DESC
),
TableName[Type]
)it worked like:
It doesn't account for customers with more then two meetings.
In that case it will simply take the type of the latest meeting and apply to all previous meetings
You can create a column like
Next meeting type =
VAR NextMeeting = OFFSET(
1,
'Table',
ORDERBY( 'Table'[Date], ASC),
PARTITIONBY( 'Table'[CustomerID])
)
VAR MeetingType = SELECTCOLUMNS( NextMeeting, "Type", 'Table'[Type])
RETURN MeetingType
If it complains that there may be duplicate rows you'll need to go into the modelling view, select the table and choose ID as the key column.
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.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 21 | |
| 14 | |
| 10 | |
| 5 | |
| 5 |