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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Victor_V
Frequent Visitor

FIRSTNONBLANK by Date and ID

Hey all,

 

I'm currently working on a report for our marketing automation campaigns. I want to figure out on which campaign the most people start with their journey. The way my table is made up is like this,

 

DateUserIDCampaign
01/01/2019AZ
08/01/2019AY
04/01/2019BY
06/01/2019BX

 

So in the case above user A starts the journey with campaign Z and user B starts with campaign Y. I tried to use the following formula to extract the first interaction: 

 

 

FirstInteraction = CALCULATE(FIRSTNONBLANK(Table[Campaign], 1), ALLEXCEPT(Table, Table[UserID]))

 

 

The problem is that this then returns campaign Y for user A and campaign X for user B, because it seems to look at the alphabetical order and not the date order in which they occured. I read that DAX apparently doesn't know the order in which your data is sorted.

Is there a way to alter the formula above (or a new one) so DAX knows to look for the earliest date of each User ID and return the campaign associated with it?

2 REPLIES 2
Anonymous
Not applicable

@Victor_V Please use below measure

Measure = 
VAR _latestdate = CALCULATE(MIN('Table'[Date]),ALLEXCEPT('Table','Table'[UserID]))
RETURN CALCULATE(FIRSTNONBLANK('Table'[Campaign],TRUE()),FILTER(ALLEXCEPT('Table','Table'[UserID]),'Table'[Date]=_latestdate))

@Anonymous It worked! Thanks a lot!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.