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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

DAX : Count rows before specific row

Hello, 

 

I'm struggling with a DAX (or logic) calculation, I have a 'Qualification' parcel Table which contains these columns : 

- Event_Biztranslist : ID of parcel

- Event_Type : Type of event 

- Event_Time : Date/Time of the event 

- Readpoint_Type : "Tunnel" or "Reader"

- Rank : for each parcel, ranking events by Event_Time (first = most ancient, last = most recent)

 

I want to count only rows before a specific row :

        [Event_Type] = "ObjectEvent" && [Readpoint_Type] "Reader" --> the combinaison occurs only once by parcels

 

First I want to qualify these rows by creating a column which will contains 1 if the row is before the row above, 0 else. 

 

To better understand : 

 

DrissChm_0-1595931339815.png

 

The screen above concerns only one parcel, I want to do it for all parcels 

 

The result in the column [Z. Check Tra before Obj] should be : 

1

1

1

0

0

0

 

Thanks in advance for your tips

 

1 ACCEPTED SOLUTION
tex628
Community Champion
Community Champion

Try this,

Column = 
VAR Parcel = 'Table'[Event_Biztransit]
VAR EventReader = Calculate( MAX( 'Table'[Event_Time] ) , ALL('Table') , 'Table'[Event_Biztransit] = Parcel , Table'[Event_Type] = "ObjectEvent" ,  Table'[Readpoint_Type] = "Reader")
Return
IF('Table'[Event_Time]<EventReader , 1 , 0 )

 


Connect on LinkedIn

View solution in original post

5 REPLIES 5
tex628
Community Champion
Community Champion

Try this,

Column = 
VAR Parcel = 'Table'[Event_Biztransit]
VAR EventReader = Calculate( MAX( 'Table'[Event_Time] ) , ALL('Table') , 'Table'[Event_Biztransit] = Parcel , Table'[Event_Type] = "ObjectEvent" ,  Table'[Readpoint_Type] = "Reader")
Return
IF('Table'[Event_Time]<EventReader , 1 , 0 )

 


Connect on LinkedIn
Anonymous
Not applicable

Nice it works 🙂

 

Screenshot tested for another parcel :

DrissChm_0-1595933293257.png

 

Thanks a lot !

Driss

tex628
Community Champion
Community Champion

No worries! Let me know if there are any other issues.


/ J


Connect on LinkedIn
tex628
Community Champion
Community Champion

Is there only 1 row that has the combination of ObjectEvent & Reader?

/ J


Connect on LinkedIn
Anonymous
Not applicable

Hello, 

 

For each parcel yes there is only one combinaison ObjectEvent & Reader

The screen shows the case for only one parcel 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.