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
fjgarcia85
New Member

Get field from previous and next row

Hello good,

create a measure to calculate the treatment field for each row taking into account the ticket field of the previous and subsequent rows, taking into account that a filtering is carried out with the following measure, showing the results that are 1.

 

filtro_informe_pendings =
IF(
    (SELECTEDVALUE('public h_cercoer_pendings'[fecha]) >= 'Date'[fecha_minima] && SELECTEDVALUE('public h_cercoer_pendings'[fecha]) < 'Date'[fecha_maxima]);
   1;
     0
)
 

fjgarcia85_1-1713525993002.png

 

Thans!!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @fjgarcia85 ,

I’d like to acknowledge the valuable input provided by @lbendlin . His initial ideas were instrumental in guiding my approach. However, I noticed that further details were needed to fully understand the issue.  

In my investigation, I took the following steps:

I create two tables as you mentioned.

vyilongmsft_0-1713753778308.png

vyilongmsft_1-1713753800452.png

Then I create a measure by using your DAX codes.

filtro = 
IF (
    (
        SELECTEDVALUE ( 'public h_cercoer_pendings'[fecha] ) >= MAX('Date'[fecha_minima])
            && SELECTEDVALUE ( 'public h_cercoer_pendings'[fecha] ) < MAX('Date'[fecha_maxima])
    ),
    1,
    0
)

vyilongmsft_2-1713753863621.png

Fianlly I create a calculated column to achieve your requirements.

Column =
VAR _CurrentTicket =
    SELECTEDVALUE ( 'public h_cercoer_pendings'[ticket] )
VAR _PreviousTicket =
    CALCULATE (
        MAX ( 'public h_cercoer_pendings'[ticket] ),
        FILTER (
            ALL ( 'public h_cercoer_pendings' ),
            'public h_cercoer_pendings'[ticket]
                < EARLIER ( 'public h_cercoer_pendings'[ticket] )
        )
    )
RETURN
    _PreviousTicket

vyilongmsft_3-1713753977733.png

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @fjgarcia85 ,

I’d like to acknowledge the valuable input provided by @lbendlin . His initial ideas were instrumental in guiding my approach. However, I noticed that further details were needed to fully understand the issue.  

In my investigation, I took the following steps:

I create two tables as you mentioned.

vyilongmsft_0-1713753778308.png

vyilongmsft_1-1713753800452.png

Then I create a measure by using your DAX codes.

filtro = 
IF (
    (
        SELECTEDVALUE ( 'public h_cercoer_pendings'[fecha] ) >= MAX('Date'[fecha_minima])
            && SELECTEDVALUE ( 'public h_cercoer_pendings'[fecha] ) < MAX('Date'[fecha_maxima])
    ),
    1,
    0
)

vyilongmsft_2-1713753863621.png

Fianlly I create a calculated column to achieve your requirements.

Column =
VAR _CurrentTicket =
    SELECTEDVALUE ( 'public h_cercoer_pendings'[ticket] )
VAR _PreviousTicket =
    CALCULATE (
        MAX ( 'public h_cercoer_pendings'[ticket] ),
        FILTER (
            ALL ( 'public h_cercoer_pendings' ),
            'public h_cercoer_pendings'[ticket]
                < EARLIER ( 'public h_cercoer_pendings'[ticket] )
        )
    )
RETURN
    _PreviousTicket

vyilongmsft_3-1713753977733.png

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

read about the WINDOW function.

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors