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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors