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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
Super User
Super User

@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
Super User
Super User

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.