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

See when key Fabric features will launch and what’s already live, all in one place and always up to date. Explore the new Fabric roadmap

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
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.