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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
swinchell
Regular Visitor

Returning a field value based on information in two columns

I need help writing a DAX function that returns the first test result for an individual user. For example, William has taken test 1 twice, but I only need to know that he passed it on attempt one. In this case, if there are multiple test results for a user, I am only interested in the first result. Thank you.

 

Sample table.

UserTest#Result
JoeTest1Pass
CarolTest1Pass
WilliamTest1Pass
WilliamTest1In Progress
StevenTest1Not Started
JoeTest2Not Started
StevenTest1Pass
CarolTest2Not Started
WilliamTest2Pass
WilliamTest2In Progress
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@swinchell , do you have date column to check the first date.

Or add an index column in power query https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

Column =

var _1 = minx(filter(table, [user] = earlier([user]) && [Test #] = earlier([Test #]) ), [index] )
return
if(_1 =[Index] && [Result] = "Pass" , 1,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @swinchell ,

 

Please refer this formula.

Measure = 
var _min_date = CALCULATE(MIN('Table'[date]),FILTER(ALLSELECTED('Table'),'Table'[User]=SELECTEDVALUE('Table'[User])&&'Table'[Test#]=SELECTEDVALUE('Table'[Test#])))
return
CALCULATE(MAX('Table'[Result]),FILTER(ALLSELECTED('Table'),'Table'[User]=SELECTEDVALUE('Table'[User])&&'Table'[date]=_min_date))

 

Best Regards,

Jay

amitchandak
Super User
Super User

@swinchell , do you have date column to check the first date.

Or add an index column in power query https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

Column =

var _1 = minx(filter(table, [user] = earlier([user]) && [Test #] = earlier([Test #]) ), [index] )
return
if(_1 =[Index] && [Result] = "Pass" , 1,0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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