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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Compare values from previous Rows on a sliced table

Hello Everyone, 

 

I'm currently trying to replicate an Excel File on Power BI and I'm facing a problem with one of the formulas that are in this file. 

 

Background : 

Data : about 1 000 000 rows

Column Description : 

  • Type
  • Date
  • Value
  • Max Value
  • Out Max = Value>Max Value

 

What I've done : 

  • I've created a slicer on Type to allow the end-user to select the type he wants and display the values.

 

What I want to do : 

I want to recreate the following  : Check for the 3Consecutive OutMax Column if the 3 Values that has been measured before my current value are OutMax = TRUE.

The ideal would be to be able to use a what if parameter to choose the number of consecutive value that I want to analyze (3,6,9... ) 

 

Thank you for your help  ! 

AndWithPreivousRows.PNG

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @Anonymous 

You need an additional colum to establish sequential order. I see that there are repeated dates so that doesn't help. If you don't have one, add an index column in the query editor (Add column - >Add index column)

Then create an additional calculated column. I'm assuming you want to check by type independently:

 

ConsecutiveOutMax =
VAR Last3_ =
    CALCULATETABLE (
        DISTINCT ( Table1[OutMax] ),
        Table1[Index] <= EARLIER ( Table1[Index] ),
        Table1[Index]
            > ( EARLIER ( Table1[Index] ) - 3 )
    )
RETURN
    IF ( FALSE () IN Last3_, FALSE (), TRUE () )

 

View solution in original post

1 REPLY 1
AlB
Community Champion
Community Champion

Hi @Anonymous 

You need an additional colum to establish sequential order. I see that there are repeated dates so that doesn't help. If you don't have one, add an index column in the query editor (Add column - >Add index column)

Then create an additional calculated column. I'm assuming you want to check by type independently:

 

ConsecutiveOutMax =
VAR Last3_ =
    CALCULATETABLE (
        DISTINCT ( Table1[OutMax] ),
        Table1[Index] <= EARLIER ( Table1[Index] ),
        Table1[Index]
            > ( EARLIER ( Table1[Index] ) - 3 )
    )
RETURN
    IF ( FALSE () IN Last3_, FALSE (), TRUE () )

 

Helpful resources

Announcements
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