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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Analitika
Post Prodigy
Post Prodigy

Select first item from filtered rows

I have a measure which return for me first item from filtered row
 
_FirstFromSelected =
VAR _Filtereditems = CONCATENATEX(ALLSELECTED(_tbl),_tbl[Company_Name],"|")
RETURN
IF(PATHCONTAINS(_Filtereditems,"Name1"),"Name1",PATHITEM(_Filtereditems,1))
 
But it not working if setted as value in other measure
OtherMeasure = 
VAR _CurrentAxis = SELECTEDVALUE ( _tbl_2[Company_Name] )
RETURN
CALCULATE(
[Measure2],
_tbl[Company_Name] = _CurrentAxis
)
-------------------------
 Measure2 =
IF (
ISFILTERED ( _tbl[Company_Name] ) = FALSE,
CALCULATE (
     Sum(_tbl[sum])
  )
 ,FILTER(_tbl,[Company_Name]=[_FirstFromSelected]) // this is not work 
// ,FILTER(_tbl,[Company_Name]="Company1") // this work very well
// also [_FirstFromSelected]="Company1" return True
)
,CALCULATE (
     Sum(_tbl[sum])
  )
)
So how to put first item from filtered rows into filter in measure to filter only this value?
3 REPLIES 3
lbendlin
Super User
Super User

Remember that a single row/single column table result will be treated as a scalar by DAX.

lbendlin
Super User
Super User

You get extra points for using PATHITEM creatively, but what's wrong with TOPN(,1)  ?

@lbendlin wrong is that it is not working as return all values instead only One scalar

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.