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! Request now

Reply
Anonymous
Not applicable

DAX code : get a value from the last row of a filtered table

Hi,

 

I have a calculated column where I want to have a binary true/false depending on another filtered table column number

 

  1. Filter the table following a particuliar string
  2. Get the last row of that filtered table
  3. Find a value in a specified column
  4. If > 7, then true and else then false

 

Data structure

 

Table1:

NameDate                           Score
A05/01/20228
B06/01/20225
B07/01/202210
A07/05/20223

 

Table2:

NameCalculated column : Last score is > 7
ANo
BYes

 

Could anyone help me get the DAX code for the Calculated column in Table2 right ?

All I have for now is to filter Table1 for only A rows.

 

Thanks

James

1 ACCEPTED SOLUTION
Shishir22
Solution Sage
Solution Sage

Hello @Anonymous ,


Give relationship between two tables based on Name and then please try calculated column as-

 

 

Column = 
VAR _MaxDate = MAXX(filter(RELATEDTABLE(Table1),Table1[Name]=EARLIER(Table2[Name])),Table1[Date])
VAR _Value= CALCULATE(FIRSTNONBLANK(Table1[Score],0),filter(RELATEDTABLE(Table1),Table1[Date]=_MaxDate))
Return
IF(_Value>7,"Yes","No")

 

 

Shishir22_0-1651829084296.png

 

Please mark it as solution if it solves your issue. Kudos are also appreciated.

 

Cheers,

Shishir

 

Cheers,
Shishir

View solution in original post

5 REPLIES 5
Shishir22
Solution Sage
Solution Sage

Hello @Anonymous ,


Give relationship between two tables based on Name and then please try calculated column as-

 

 

Column = 
VAR _MaxDate = MAXX(filter(RELATEDTABLE(Table1),Table1[Name]=EARLIER(Table2[Name])),Table1[Date])
VAR _Value= CALCULATE(FIRSTNONBLANK(Table1[Score],0),filter(RELATEDTABLE(Table1),Table1[Date]=_MaxDate))
Return
IF(_Value>7,"Yes","No")

 

 

Shishir22_0-1651829084296.png

 

Please mark it as solution if it solves your issue. Kudos are also appreciated.

 

Cheers,

Shishir

 

Cheers,
Shishir
Anonymous
Not applicable

I can't put

filter(RELATEDTABLE(Table1),Table1[Date]=_MaxDate)

in var _Value, it doesn't show "Table1[Date]" as criteria

 

I have added a picture showing the link between my table : Note de la zone.png

In orange "derniere_note" is the last note of the left table, depending on the zone.

In yellow the link between the table : left tables has multiple entries corresponding to on entry in the middle table (2 columsn highlighted because I can do the link with both columns)

In green the columns we can use to rank the entries, the ID --> ID+1 each time a new row is made

Anonymous
Not applicable

EDIT :

 

 

Column = 
VAR _MaxDate = MAXX(filter(RELATEDTABLE(Table1),Table1[Name]=EARLIER(Table2[Name])),Table1[Date])
VAR _Value= CALCULATE(FIRSTNONBLANK(Table1[Score],0),filter(RELATEDTABLE(Table1),Table1[Date]=_MaxDate))
Return
IF(_Value>7,"Yes","No")

 

 

does not work becaus einstead of related table you shouldnjust use Table, as :

 

 

Column = 
VAR _MaxDate = MAXX(filter(RELATEDTABLE(Table1),Table1[Name]=EARLIER(Table2[Name])),Table1[Date])
VAR _Value= CALCULATE(FIRSTNONBLANK(Table1[Score],0),filter(Table1,Table1[Date]=_MaxDate))
Return
IF(_Value>7,"Yes","No")

 

 

 

@Shishir22 , please edit your post so when new people come see they get the accepted answer as correct directly.

 

thanks everyone 🙂

ribisht17
Super User
Super User

@Anonymous 

 

STEP1

RANK COL = RANKX(FILTER( 'True False','True False'[Name]=EARLIER('True False'[Name])),'True False'[Date])
 
STEP2
Latest > 7 = IF('True False'[Score] > 7 && 'True False'[RANK COL]=1,"Yes","No")
 
STEP 3
 
Solution = MAXX(FILTER(ALL('True False'),'True False'[Name]=EARLIER('True False'[Name])) ,'True False'[Latest > 7])
 
 
ribisht17_0-1651829604198.png

 


 

 
Regards,
Ritesh
Anonymous
Not applicable

Could you explain the code ? I copied paste it and changed the columns names to my columns names, and it doesn't seem to work.

I have added a picture showing the link between my table : 

James_C_0-1651830744919.png

 

In orange "derniere_note" is the last note of the left table, depending on the zone.

In yellow the link between the table : left tables has multiple entries corresponding to on entry in the middle table (2 columsn highlighted because I can do the link with both columns)

In green the columns we can use to rank the entries, the ID --> ID+1 each time a new row is made

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors