Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next 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

Reply
sumsar10171
Frequent Visitor

DAX expression for finding the new row for a given customer

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:

IDCustomerIDDateType
112023-02-01Startup
222023-02-01Retention
332023-02-01Startup
422023-02-05Support
512023-02-05Adjustment

 

What I'm looking for:

IDCustomerIDDateTypeNext meeting type
112023-02-01StartupAdjustment
222023-02-01RetentionSupport
332023-02-01Startup 
422023-02-05Support 
512023-02-05Adjustment 

 

 

 

5 REPLIES 5
smpa01
Community Champion
Community Champion

@sumsar10171  with new DAX OFFSET; PFA

Measure = 
CALCULATE (
    [__type],
    OFFSET (
        1,
        DISTINCT ( ALL ( tbl ) ),
        ORDERBY ( tbl[Date], ASC ),
        KEEP,
        PARTITIONBY ( tbl[CustomerID] )
    )
)

 

smpa01_0-1676042306847.png

 

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Is it possible to write this as a column? 

 

FreemanZ
Community Champion
Community Champion

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:

FreemanZ_0-1676038478679.png

 

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

johnt75
Super User
Super User

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.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.