Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
User | Test# | Result |
Joe | Test1 | Pass |
Carol | Test1 | Pass |
William | Test1 | Pass |
William | Test1 | In Progress |
Steven | Test1 | Not Started |
Joe | Test2 | Not Started |
Steven | Test1 | Pass |
Carol | Test2 | Not Started |
William | Test2 | Pass |
William | Test2 | In Progress |
Solved! Go to Solution.
@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)
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
@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)
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
13 | |
11 | |
9 | |
6 |