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 dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I have a problem that I cannot resolve.
here is my table:
Date | Student Name | Subject | Test Result |
08-Dec-23 | Amir A. | Math | 80 |
10-Dec-23 | Amir A. | Math | 90 |
05-Nov-23 | Baruch B. | History | 70 |
01-Dec-23 | Amir A. | Science | 65 |
01-Oct-23 | Baruch B. | Math | 92 |
1-Sep-23 | Baruch B. | Math | 85 |
I would like to have a column that indicates the last "Test Result" based on the Student Name and Subject.
for Amir A. - Math - I would like to get 90, because the test was done on Dec, 10th
for Baruch B. - Math - I would like to get 92
for Baruch B. - History - I would like to see 70
is this possible using a DAX in a column?
it's OK to get the number 90 for all rows of Amir A. , Math.
Thank you in advance,
Yuval
Solved! Go to Solution.
Create a new column and paste the following expression:
Note: Make sure to change 'Sheet1' to your table name.
@yuvalpi you can also do this
Measure =
VAR _grouping =
ALLEXCEPT ( 'Table 1', 'Table 1'[Student Name], 'Table 1'[Subject] ) //define GROUPBY columns here
VAR one =
CALCULATE ( MAX ( 'Table 1'[Date] ), _grouping ) // what is the max date by the above group
VAR two =
CALCULATE ( MAX ( 'Table 1'[Test Result] ), _grouping, 'Table 1'[Date] = one ) //what is the test result on max date partioned by grouping
RETURN
two
@yuvalpi you can also do this
Measure =
VAR _grouping =
ALLEXCEPT ( 'Table 1', 'Table 1'[Student Name], 'Table 1'[Subject] ) //define GROUPBY columns here
VAR one =
CALCULATE ( MAX ( 'Table 1'[Date] ), _grouping ) // what is the max date by the above group
VAR two =
CALCULATE ( MAX ( 'Table 1'[Test Result] ), _grouping, 'Table 1'[Date] = one ) //what is the test result on max date partioned by grouping
RETURN
two
Hi smpa01,
I tried your solution and it also works great!
much appreciated!
thank you,
Yuval
Hi Bibiano_Geraldo,
This is amazing!! thank you so much for you quick and proffessional help!
much appreciated,
Yuval
Create a new column and paste the following expression:
Note: Make sure to change 'Sheet1' to your table name.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
63 | |
59 | |
56 | |
38 | |
29 |
User | Count |
---|---|
82 | |
62 | |
45 | |
41 | |
40 |