Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I have a table with StudentID, Score and TestDate columns. I am trying to identify the difference in scores between two dates. When there are only two TestDates for a student then I can manage that, however when there are more than 2 then there's a problem with my dax.
Here's what i am trying to achieve;
StudentID, Score, TestDate, DifferenceinScore
stud001, 90, 2019-01-15, blank
stud001, 95, 2019-01-20, 5
stud001, 96, 2019-02-15, 1
How could i do this in a calculated column?
thanks
Solved! Go to Solution.
Hello @rishtin
Give this a try.
Score Change = VAR CurrStudent = 'Table'[StudentID] VAR CurrDate = 'Table'[TestDate] VAR PrevTestDate = CALCULATE( MAX ( 'Table'[TestDate] ), ALL ( 'Table' ), 'Table'[StudentID] = CurrStudent, 'Table'[TestDate] < CurrDate ) RETURN IF ( NOT ISBLANK ( PrevTestDate ), 'Table'[Score] - CALCULATE( MAX ( 'Table'[Score] ), ALL( 'Table' ), 'Table'[StudentID] = CurrStudent, 'Table'[TestDate] = PrevTestDate ) )
Hello @rishtin
Give this a try.
Score Change = VAR CurrStudent = 'Table'[StudentID] VAR CurrDate = 'Table'[TestDate] VAR PrevTestDate = CALCULATE( MAX ( 'Table'[TestDate] ), ALL ( 'Table' ), 'Table'[StudentID] = CurrStudent, 'Table'[TestDate] < CurrDate ) RETURN IF ( NOT ISBLANK ( PrevTestDate ), 'Table'[Score] - CALCULATE( MAX ( 'Table'[Score] ), ALL( 'Table' ), 'Table'[StudentID] = CurrStudent, 'Table'[TestDate] = PrevTestDate ) )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
84 | |
67 | |
59 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |